Hi....
I have an enemy that goes from PointA to PointB and then from PointB to PointA....
Here is the script..
var pointB : Vector3;
function Start () {
var pointA = transform.position;
while (true) {
yield MoveObject(transform, pointA, pointB, 3.0);
yield MoveObject(transform, pointB, pointA, 3.0);
}
}
function MoveObject (thisTransform : Transform, startPos : Vector3, endPos : Vector3, time : float) {
var i = 0.0;
var rate = 1.0/time;
while (i < 1.0) {
i += Time.deltaTime * rate;
thisTransform.position = Vector3.Lerp(startPos, endPos, i);
yield;
}
}
I am new to unity and i need a little help... I want when my enemy goes to PointB to rotate 180 and go back to pointA...but i dont know how to do it...Thank you.