2dkot
1
Well I try to make object move to point A and then go to point B. Well what I an doing wrong? Object stops at point A and do nothing, less words - more code:
var i: int;
public var point_arr: Vector3[];
var point_move: Vector3;
var myTarget:GameObject;
var myDistance;
function Start(){
i = 0;
}
function myMove(mytarget: Vector3){
transform.LookAt(mytarget);
transform.Translate (Vector3.forward*Time.deltaTime*15);
}
function Update () {
myDistance = Vector3.Distance(transform.position,point_arr*);*
if(myDistance>0){
myMove(point_arr*);
_}_
else{i = i + 1;}
_}*_
You’re moving Time.deltaTime*15 units each frame. Unless you are incredibly lucky, the total displacement will never match exactly point A, so myDistance will never be 0. Compare myDistance to some reasonable value, and it will work:
...
if (myDistance > 0.5){
myMove(point_arr*);*
*}*
*...*
**