Advanced 3rd Person Camera

Started by
11 comments, last by spencerholmes 18 years, 9 months ago
Hi, I am writing a small 3d sonic the hedgehog game. I've written a 3rd person camera class, but i want it to act like the one in the official sonic games. In sonic heroes (SA2, SA1 etc.) the camera does not exactly follow the player, but allows the player to run around in its view, but it rotates to follow the track of the level. This is kinda hard to explain... In this image you can see what i mean, the camera views the direction of the level but it is not behind sonic. Does anyone know how this is achieved, im assuming some kind of stored camera path? I thought perhaps it follows a curve through waypoints, but the camera does move side to side slightly too. It isnt totally fixed on a curved path. Anyone have any ideas on how i can recreate this in my game? Cheers Luke.
Member of the NeHe team.
Advertisement
i havent played the game so im guessing, perhaps u wanna smooth the camera movement out? check flipcode from a few years ago, see one of the ask midnight column's, where camera movement is based on the average over a few frames
The 3rd person camera is best implemented with quaternions and spherical linear interpolation (slerping). This creates smooth rotation transitions and it's easy to hook the camera up to the player on-screen (in this case, Sonic), or give control to the user.
I could give you some tips on smoothing the movement of your camera, but I think your issue is higher level. Okay, so I assume you know that player motion is relative to the camera's orientation to the player... when you press forward on the joystick, the player runs in the direction the camera is facing to the player.

So your question is actually two competing ones: 1) What happens when I want the camera to face a certain direction and 2) How do I let the user control the camera at the same time?

I encourage you to very thoroughly examine the Jak & Daxter camera, it's really the highest quality, most flexible camera system in many cases. In their case, when they use the camera to point you forward in the level they take away user control while the camera rotates into position, then put it completely back in user control once they've pointed out the objective. There are other modes where they'll lock the camera's orientation to a perspective relative to the viewer, or they'll pivot the camera around a point in the distance and focus on the player.

They key is: when you want to unexpectedly change the orientation of the camera, do it very quickly and all at once. Because the semantic direction of what pressing 'forward' means (the direction the player expects to move) changes with the orientation of the camera, it is very bad to change it unnecessarily or unexpectedly (though sometimes it is necessary).
Hi. Can't you update the position of the camera to the position of the character just a few pixels out and up. You could use something like:

_pcamera = new CCamera;
_pcamera->SetPosition(_this->_psonic->Getx()+10, _this->_psonic->Gety()+10, _this->_psonic->Getz()+10);

maybe that would work?
Thanks for the replies, but i think you all misunderstand me (except perhaps ajas95). I already have a 3rd person camera, thats not a problem, my camera follows behind the player. What i need is a way for the camera to stay focused on the player, but the position of the camera does not necessarily follow the player. I believe I can achieve what I want by making the camera position follow a series of control points through the level, i just need to work out the maths now :)

Anyone have any decent links on bezier curves? More specifically finding the closest point on a curve to another point.

Cheers

Luke.
Member of the NeHe team.
bezier curves whilst easy dont go through the control points, myself i bsplines as they go through the control points
paul bourkes site has good mathmatical stuff

http://astronomy.swin.edu.au/%7Epbourke/index.html
man, I think this can be done in many ways. One of them, apply direction of object to direction of camera, put camera back from object with reverse direction and add some 'up' value ... (z for example)
HMMM...,. what do you want exactly ? I think nobody understands it
Sorry, its hard to explain. I've worked out some of it myself. So now all i need to do is work out how to make a camera follow a curved path through a map. But it needs to be able to move back and forward along this path based on the position of the players character.

I need to find the point on a curve nearest to the position of a player.

Hope that helps,

Luke.

P.S. Cheers Zedzeek that helps a lot.
Member of the NeHe team.

This topic is closed to new replies.

Advertisement