hey guys
i need to make a script that i can apply to a player, so that when he gets close to an object, certain code is run… I don’t understand that much about raycasting, and i’ve seen people recommending to do it all different ways, like with spheres.
Can someone please help me out!!!
thanks
-Grady
how would you do that with javascript?
– GradesFisherso where it says "badplace.position" would i change that to the object that i want to see if the player is near?
– GradesFisherYes. The script might have that as a variable: var badplace : Transform; you then drag the appropriate game object to that variable in the inspector.
– Wazthis is my code: var objective : Transform; function Update () { if (Vector3.Distance(transform.position, objective.position) < 10){ Application.LoadLevel("game_scene_01"); } } the console has no errors to do with this script, but when i get right close to the object, nothing happens... is it something to do with using the Update() function or is it meant to be a different function? thanks
– GradesFisherno its ok, i must have forgot to do something because its working now!!!!!!! Thanks a lot! -Grady
– GradesFisher