Help!!! Im a newbie in unity and javascript.
I want my character move to next scene after it hits the given distance(fixdist).
Here’s my code:
var targetObject : Transform;
function Start(){
targetObject = GameObject.Find("First Person Controller").transform;
}
function Update(){
var fixdist : float = "179.3872";
if (targetObject!= null){
var dist : float = Vector3.Distance(targetObject.position, this.transform.position);
print ("Distance to target Object: " + dist);
if (targetObject)
Application.LoadLevel(1);
What do you mean by "If this script is in the startpoint"? Sorry, I'm still a newbie to unity and javascript. Thanks anyway. How can I also refer the dist to my targetObject?
– jongYou need to add this script component to a startpoint, even a empty object.
– FLAh, okay, I get your point. Thanks
– jong