Archived

This topic is now archived and is closed to further replies.

Keeping the player in the middle of the screen??

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

If you''re using gluLookAt to position the camera, then you just need to make the camera look at your object and position the camera a little bit behind it.
gluLookAt(player.x, player.y, player.z - 10, player.x, player.y, player.z, upvector.x, upvector.y, upvector.z);

i think that should do the trick.

Share this post


Link to post
Share on other sites
I do the exact same thing, except, instead of keeping the player in the middle - I keep a spacecraft in the middle.
I do not use gluLookAt. I just apply all of the transformations to all the things that should be zooming by while the player would be "moving". In other words, instead of moving the player 3 units on the Y-Axis, I move a tree -3 units on the Y-axis.
It is really simple, once you get the hang of it.

Hope this helps,

TommyB

Share this post


Link to post
Share on other sites
I have also been trying to solve this problem... I understand what you mean about the camera following the character around the screen but, i dont know how you get the position the character is facing. What i have for now is a cube that is infront of the camera, using a gluLookat eventually i dont want to actually see the character only look though its eyes. The only person that will see this character is someone looking at it though a network. So i need to me able to store those varibles (xPos,YPos,zPos, yRot,xRot, ZRot) somewhere right now i have a structure to keep track of it. I can sort of get the camera to follow the cube, but i cant get it to rotate with the camera, when i us ethe mouse. Im not sure if im explaining it clearly or not.

If you need to see the exe or source code to help let me know either replying to this message or sending me an email at E_Williams@Rogers.com.

Share this post


Link to post
Share on other sites