### Author Topic: turn object to face another object slowly  (Read 1867 times)

#### slenkar

• byte
• Posts: 20
##### turn object to face another object slowly
« on: May 30, 2009, 04:06:52 am »
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?
« Last Edit: May 30, 2009, 04:20:27 am by slenkar »

#### EgonOlsen

• Posts: 11829
##### Re: turn object to face another object slowly
« Reply #1 on: May 30, 2009, 08:47:18 am »
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

• byte
• Posts: 20
##### Re: turn object to face another object slowly
« Reply #2 on: May 30, 2009, 05:10:42 pm »
so i would interpolate between the dummy and object1's matrices?

« Last Edit: May 30, 2009, 05:37:13 pm by slenkar »