- Home /
Question by
CalledToGaming · Mar 08, 2010 at 12:46 AM ·
distanceactivateclickable
How do I set a maximum distance on an activate-able object?
How do I tell the system what the maximum distance is from an object before it can be activated. For example, I have a door that is clickable which loads the next scene when you click it. However, weather I'm next to it, or 100yards away, i can still activate it. How do I set the maximum distance allowed to activate it?
Comment
Best Answer
Answer by Sebas · Mar 08, 2010 at 01:19 AM
Firstly, you would calculate the distance between player and door either using Vector3.Distance or better Vector3.sqrMagnitude and you would then add an if statement to your clickable object so that the functionality is only triggered when your distance is smaller than a certain amount.