y-axis rotation of camera match object

This topic is 4963 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I am trying to get the y-axis rotation of the camera to correspond with the rotation of an object; the object is aligned with the camera on its front vector does anyone have any suggestions/help on how to do this; so it rotates correctly? I have a y-axis based rotation I use for the camera; its stored as a float, but that doesn't seem to help. I tried setting that to the rotation of the object and it kinda would spin fast as I turned right and slow back down if I turned left. [Edited by - DevLiquidKnight on June 17, 2005 10:17:12 PM]

Share on other sites
If I understood correctly, what you are trying to do is:
object.rotation.y = camera.rotation.y + PI;

Share on other sites
No, that didn't work basically im trying to make the camera itself be a 3rd person camera view.

Share on other sites
according to Game Programming Gems 2, there is an article about "Mario 64", a 3rd person control.

u need 3 direction vectors, camera's front vec, right vec & input's dir vec, 1st an alternative normalized camera front vec :
vDir.x=cam->front.x;vDir.y=0;vDir.z=cam->front.z;normalize(vDir,vDir);

2nd, an alternative normalized camera right vec :
vRight.x=cam->right.x;vRight.y=0;vRight.z=cam->right.z;normalize(vRight,vRight);

then the input dir vec, assume up(y)=1, down(y)=-1, left(x)=-1, right(x)=1. Normalize it also.

so the final Direction Vector for character is :
final.x=(input.x * vRight.x) + (input.y * vDir.x);final.y=0;final.z=(input.x * vRight.z) + (input.y * vDir.z);normalize(final,final);

then if u need the Y-radius of the final vector, do the following:
radius=-atan(final.z/final.x);if (final.x>0.0f)  radius-=D3D_HALFPI;else  radius+=D3D_HALFPI;

• What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 28
• 16
• 10
• 10
• 11
• Forum Statistics

• Total Topics
634106
• Total Posts
3015547
×