Advertisement

Look at point in 3d

Started by November 01, 1999 01:37 PM
0 comments, last by GameDev.net 24 years, 10 months ago

Hi,

I want to make a character that look to a point (x,y,z). Like Tombraider and Grim Fandango.
And if I move the point, the character move his/her head always looking the point.
Is there some code or ideas about it.

Thanks in advance.

Leo.

Okay, you know how to draw 3D so this should be fairly simple.

If you have a character's head and a point to look at, then it fairly simple to find two angles which represent the x and y rotations by trigonometry.
You can find the x rotation by the difference in height between the head and the point and the distance in the y plane between the head and the point, using arcsin

You can find the y rotation by the distance between the head and the point in the x and z vectors using arcsin again.

Then rotate the head in the x then the y.

Sorry, but if I could draw, I'd do diagrams...

If this does not make sense, I suggest try drawing it on paper first....

This topic is closed to new replies.

Advertisement