Jump to content
Posted 18 July 2014 - 08:32 PM
Posted 20 July 2014 - 07:00 AM
Start with the facing vector of one character. Calculate the vector from that character to the other. For just the angle: the angle theta between the facing direction and the "new" direction can be determined from the cross product |a| |b| sin(theta) n, or the dot product |a| |b| sin(theta).
Rather than being directly concerned with the angle, calculate 2 quaternions: one for the facing direction, one for the new direction. SLERP between the two over a short period of time (however long you want it to take for the character to turn).
Quaternion qFace, qNew, qCharacter; ... qCharacter = SLERP(qFace, qNew, t); // t goes from 0 to 1 and is the fraction of time to take to turn from one direction to the other
Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.
You don't forget how to play when you grow old; you grow old when you forget how to play.