Any idea how do I move an object in loop from point A to Point B when it reachs a Point C?
Thanks.
Any idea how do I move an object in loop from point A to Point B when it reachs a Point C?
Thanks.
http://itween.pixelplacement.com/
Look at the "callback functions" demo.
Not sure if that's what you want, but to check if Point C was reached you can use a Trigger. (Collider that is setup as a trigger) To move something from A to B over a fixed amount of time you can write a Coroutine which is starte when Point C is reached. The coroutine would look something like this:
IEnumerator MoveTo(Vector3 start, Vector3 target, float time) {
float startTime = Time.time;
while (transform.position != target) {
transform.position = Vector3.Lerp(start, target, (Time.time - startTime) / time);
yield return 0;
}
}
To start the coroutine the trigger object will need a script like this:
void OnTriggerEnter(Collider c) {
c.GetComponent<MyScript>().StartCoroutine(MoveTo(start, target, time));
}