turn object to face another object slowly

Started by slenkar, May 30, 2009, 04:06:52 AM

Previous topic - Next topic

slenkar

when i was using another 3d engine i did this:

1.created a dummy object and made it a child of object 1
2.pointed the dummy to object2 (target object)
3.got local yaw and pitch of dummy (relative to its parent)
4.increased/decreased yaw(yaxis) and pitch(xaxis) of object1 by a certain amount  (depends how good the ships turn thrusters are)
(in  my game you can upgrade turn thrusters so ships can turn to face another quicker)

if the dummys yaw is bigger than object1
reduce object1's yaw by turn thruster amount
if the dummys yaw is smaller than object1
increase object11's yaw by turn thruster amount

if the difference of the dummys yaw and pitch compared to its parent are less than the ships turn thruster amount, then just set the yaw and pitch as the same
5.set roll (zaxis) as the same for every object (zero) to make them look better, so that no ship looks upside down


is this possible in jpct?

EgonOlsen

There's a method to interpolate between matrices in Matrix. When used on the source's rotation matrix with the target's one as, well...target, the ship should slowly turn towards the target. It might cause problems if the matrices are very different and the interpolation is coarse, but i've never experienced this in real life. The camera movement and the bot's turning in Robombs are done this way.

slenkar

#2
so i would interpolate between the dummy and object1's matrices?


EgonOlsen

If i understood you correctly, that would be an option.