Cameras, first person or third person

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
nayon
Posts: 16
Joined: Mon Mar 16, 2009 1:07 pm

Cameras, first person or third person

Post by nayon »

Hello, I've been scanning the forums for the last few hours but I can't seem to find an answer for my problem.

Apparently, the FPS camera built into irrlicht is not good. Yes, I understand it is for demonstration purposes. There is bunnyhopping and you can jump while in the air which makes you fly indefinitely. And there are other issues too. I haven't found a single thread with a camera that actually works, responds to gravity and takes care of these issues.

Same applies to third person. There are some threads, but the code in them is not compatible with 1.6. Event receiver abstract class stuff and even when you make them work, they're not really that good. Some of them don't have strafing, and most of them need you to drag the mouse to turn around.

Am I missing something? Is there a good camera? If not, how can I implement a good FPS camera? I have no idea where to begin, how to check whether I'm on the ground (I tried casting a ray downwards but that's wonky) and deal with the collision animator's gravity while jumping.

Could someone either post a proper example or give me enough advice to make my own camera please? Third person isn't really an issue, it's just something I noticed, but the first person thing is really bugging me.
kburkhart84
Posts: 277
Joined: Thu Dec 15, 2005 6:11 pm

Post by kburkhart84 »

I recommend you code it yourself. You will need a little bit of trigonometry(or know how to use vectors) to calculate the movement. You set the rotation and position of the camera similar to other scene nodes, though rotation may or may not work depending some setting(don't remember which). On the other hand, you can use the lookAt vector to control rotation anyway.

On the other hand, you can duplicate the current FPS camera that you don't like, and "fix" it so you do like it. I think that may be more difficult though because it is done a certain way, and you may not want that for your game.
Brainsaw
Posts: 1176
Joined: Wed Jan 07, 2004 12:57 pm
Location: Bavaria

Post by Brainsaw »

The 3rd person camera (actually the 3rd marble camera) in my current project doesn't apply any movement. It just follows the object (the movement of which is calculated using ODE). But the mathematical stuff is in there, so you couls grab my project "marbles2" and take a look into the "CFollowMarbleCameraAnimator" (or something like this ... don't have the sourcecode here at work) for a 3rd person camera. The animator also moves the camera so that it will not get to a position where another object is between the camera and the followed object.
Dustbin::Games on the web: https://www.dustbin-online.de/

Dustbin::Games on facebook: https://www.facebook.com/dustbingames/
Dustbin::Games on twitter: https://twitter.com/dustbingames
nayon
Posts: 16
Joined: Mon Mar 16, 2009 1:07 pm

Post by nayon »

So you're saying there is no "proper" fps camera (like ones in actual games)? I'm asking because I don't want to reinvent the wheel unless I have to.

What kind of method should I use to check whether the 'player' is on the ground?
Brainsaw
Posts: 1176
Joined: Wed Jan 07, 2004 12:57 pm
Location: Bavaria

Post by Brainsaw »

I would use a physics engine for that. Or use the built-in collision system of Irrlicht. On the ODE wiki there is an article about using an "upright capsule" (with restricted rotation) for the player. I guess this can be done with Irrlicht collision detection as well.
Dustbin::Games on the web: https://www.dustbin-online.de/

Dustbin::Games on facebook: https://www.facebook.com/dustbingames/
Dustbin::Games on twitter: https://twitter.com/dustbingames
Post Reply