I’m writing a script that will allow the player to walk up to an NPC and press a button to talk. Obviously, the character needs to be a certain distance to talk. So I wrote a basic script to test it out:
var char : Transform;
var can_talk = 0;
function Update () {
if (Vector3.Distance(char.position, transform.position) < 20 ) {
can_talk = 1;
print ("You can talk to this character!")
}
}
I always start the camera on the other side of the island were my game is. I’m sure that the distance is greater than 20, but it still prints “You can talk to this character!”. Any thoughts?[/code]
EDIT: Nevermind, I fixed it.