- Home /
A question on distance
I want to write a script saying,
eg. if player is one meter or less from the door, player can open it.
But, how do you do this? I know unity measures by default in meters but would write this in a script? Is it just literally:
(I know this is not javascript. It is an example...)
if(object "1 METER >); player can open door... Please help.
look in the documentation for words like "distance"
http://docs.unity3d.com/Documentation/ScriptReference/Vector3.Distance.html
have you ever used Unity? in the INSPECTOR, click on any of the small "book" icons.
that will open the DOCU$$anonymous$$ENTATION.
click SCRIPTING.
there is a search field. type in "distance"
Answer by Muuskii · Oct 08, 2012 at 07:27 PM
You can also do a Google search anytime that you're stuck on a problem. Really; whatever you're doing, one hundred people have probably done it, gotten stuck and asked a question about it.
Which makes things really easy when you want to avoid common mistakes the first time.
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Button at one end of the room opens door on other 0 Answers
my script not working..!!! 1 Answer
Door Opening And Closing 2 Answers
Help with door animation 1 Answer