Answer the question
In order to leave comments, you need to log in
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
if(Vector3.Distance(current.position, target.position) < 30)
{
Destroy(target.gameObject);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question