G
G
Gregory2562021-10-04 10:32:07
Unity
Gregory256, 2021-10-04 10:32:07

How to stop an object at a certain distance from another object?

Good day, dear experts, please tell me how you can stop the object (player) at a certain distance from the collision.
For example: there are two objects on the stage, if the player is at a distance less than 30 from another object, then the object disappears.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
NoNameDeveloper, 2021-10-04
@Gregory256

if(Vector3.Distance(current.position, target.position) < 30)
{
    Destroy(target.gameObject);
}

N
Nekit Medvedev, 2021-10-06
@NIKROTOS

stop or delete?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question