- Home /
Question by
LucasGPires · Mar 16, 2013 at 11:25 PM ·
javascriptgame
I want to have the map of the Hidden Object game, when the player is near the object and it press the letter "Q". The object is revealed to the player.
How to program in JavaScript?
I want to have the map of the Hidden Object game, when the player is near the object and it press the letter "Q". The object is revealed to the player.
thank you
Comment
Answer by robertbu · Mar 16, 2013 at 11:38 PM
Put a script on your object. Anything under 'showDistance' will show the object. Untested.
var showDistance = 3.0;
private var goPlayer : GameObject;
function Start() {
goPlayer = GameObject.Find("Player"); // Assumes the player is named "Player"
}
function Update () {
renderer.enabled = ((goPlayer.transform.position - transform.position).magnitude < showDistance);
}
Answer by LucasGPires · Mar 19, 2013 at 12:51 AM
robertbu, and now how do I run this function so if I click a certain button