Sign in to follow this  
rm2000

Quick question about 3rd person models

Recommended Posts

rm2000    122
Excuse the n00b question but to date I have been programming my 3rd person game where as the player object follows the camera. Is this the best way to do it or should the camera be following the object? Finally if the camera is supposed to be drawing the object then how do you determine the view vector for the model? I'm just looking for some theories here on the best way to get the job done. Thanks!

Share this post


Link to post
Share on other sites
Saruman    4339
You currently have it backwards, the camera should be following the player and making adjustments for height, etc along the way. The camera doesn't draw the object, the object is just an entity in the scene, the camera just follows that specific entity.

Share this post


Link to post
Share on other sites
JohnBolton    1372
When you turn, does the camera turn and the player run over to get in front of it, or does the player turn and the camera move to get behind him? I guess that determines if you should have the camera follow the player or vice versa.

Share this post


Link to post
Share on other sites
rm2000    122
Thank you for the thoughts...Right now the camera moves through the world and then is moved to the camera x and z position every time the scene is rendered using gltranslatef. Then I calculated the angle of rotation whenever my camera moves and applied that to the model. It seems kind of convulted but it works. However, I have to figure out how to do it the other way I guess if I ever want to get other players in there :)

Here is my question. I have a MD2 or 3DS model or whatever and I load it into the arena that I have. When the player model is loaded in how do I know what direction it is facing for movement? In other words for movement I have to figure out which way the model is facing and then somehow get its view vector to make it walk that direction. Is there some sort of algortihm that is standard out there to make this happen?

To date this is why I had the model following and rotating the camera. I couldn't find any good resources on how to make it go the other way. Any assistance is appreciated...Thanks!

Share this post


Link to post
Share on other sites
Saruman    4339
Quote:
Original post by JohnBolton
When you turn, does the camera turn and the player run over to get in front of it, or does the player turn and the camera move to get behind him? I guess that determines if you should have the camera follow the player or vice versa.


No, at least not in my opinion. The player should be an entity and the camera follows it if built properly. If you want the camera to move behind or lag behind the character than you would perform those calculations on the camera, same goes for player lag. There is no reason at all to have the player follow the camera or to have the camera draw the player.. unless there is an example I am missing out on here?

I will try and get some time later today for a better response to the next post, I just have to run right now, time to go home :)

Share this post


Link to post
Share on other sites
Toji    535
"Logically" I think most people can better grok the idea of the camera following the entity in question. it simply makes more sense when paired with our view of how the world (real or virtual) works. If you're filming a movie, you don't strap your actor to the camera, you have the camera follow him.

"Technically," however, you will get the same visual effect with either method. It's rather like setting up a camera in openGL. Since there is no seperate "view" matrix like D3D, you have to think in reverse. Want to move your camera left? Move your entire scene right. It's slightly counterintuitive, but if implemented correctly no one can tell the difference.

I would simply consider what your needs for the system are:

Is your camera going to constantly follow a single entity, or do you need it to be able to switch? If the latter you probably want a independant camera that you can assign to follow any entity.
Are other people going to be working on your code? In a multiple programmer environment it's usually best to stick to standards.
How is your scene graph set up? Your collision detection? The very structure of your engine may dictate one method or the other.

Share this post


Link to post
Share on other sites
rm2000    122
I would like to thank everyone for their time. Really the only reason I've been doing 3rd person perspective in the way I am now is because I referenced a 3rd person perspective tutorial out on GameTutorials and they hinted that was one good way to do it. I built a lot of my engine around that theory but I am starting to see some limitations that I need to get around and I think by having the camera follow the object I would be able to get around those limitations. I played with it some this afternoon and I am already having some success flipping it around the other way but there are a few kinks I need to work out yet.

I may run into a question or two as I do it so hopefully you all will have some insight for me. This thread was helpful, thanks!

Mark :)

Share this post


Link to post
Share on other sites
mrbastard    1577
Quote:
Original post by rm2000When the player model is loaded in how do I know what direction it is facing for movement? In other words for movement I have to figure out which way the model is facing and then somehow get its view vector to make it walk that direction. Is there some sort of algortihm that is standard out there to make this happen?


Most models start off facing down the positive z axis, but it's just down to however they were positioned in the editor. So there's no way to be certain except to agree with your team to do it a certain way (or use whatever is most standard for the files you are using).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this