x


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?

more ▼

asked Mar 08 '10 at 12:46 AM

CalledToGaming gravatar image

CalledToGaming
190 21 24 30

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered Mar 08 '10 at 01:19 AM

Sebas gravatar image

Sebas
4.1k 12 18 45

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3419
x373
x81
x27

asked: Mar 08 '10 at 12:46 AM

Seen: 1271 times

Last Updated: Mar 08 '10 at 12:46 AM