- Home /
Question by
KarolisAndKO · May 27, 2013 at 06:15 PM ·
directionmovinggameobjectself
One direction self moving
Hi, any suggestions how to make it move only in one point? Only from Point A to Point B
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 = 0.3/time;
while (i < 1.0) {
i += Time.deltaTime * rate;
thisTransform.position = Vector3.Lerp(startPos, endPos, i);
yield;
}
}
Comment
Your answer
Follow this Question
Related Questions
how to build a 2d character which can faced 2 directions(left and right), with high performance 1 Answer
Attempting to add wheel friction to a 2d car 1 Answer
Pointing Object in the Direction it is going 1 Answer
direction/inertia touch system (2d) 1 Answer
[C#] Using the same input option to start and stop movement 2 Answers