Fall 2006»CSCI 299 Vectors Extra

CSCI 299 Vectors Extra

Follow the Leader

You have two objects, ob1 and ob2 moving in space, and you wish to ob2 to follow ob1.

1) Easier set ob2.velocity to ob1.velocity - instantenous turn

2) smooth turn - get angle diff between ob1.vel and ob2.vel. get cross product of ob1.vel and ob2.vel. set ob2.vel to rotate (ob2.vel, min(angle_diff, maxTurningCapacity), crossProduct)