- Home /
Question by
Zacharianinjaa · Jul 23, 2012 at 07:13 PM ·
javascriptvariablesmovechildrenwaypoint
move childA to position of childB
I have an object named Player and it has 2 children named PlayerObj and WayPoint. I need to do 1 of 2 things; either from the parent, Player, move the PlayerObj to WayPoint or i need to move PlayerObj to Waypoint within a script on PlayerObj. I have been searching for a few days with no resulst. Im writing in Javascript so anyway anyone could help would be great.
Comment
Answer by Seth-Bergman · Jul 23, 2012 at 09:53 PM
on the PlayerObj:
var wayPoint : GameObject;
var speed = 10.0;
function Start(){
wayPoint = GameObject.Find("WayPoint");
}
function Update(){
transform.position = Vector3.Lerp(transform.position,wayPoint.transform.position,Time.deltaTime * speed);
}
Thanks a ton it worked. Is there anyway to get it to move at a constant rate thou?