How to implement a driver cam?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Hirogen
Posts: 19
Joined: Tue May 29, 2007 5:55 am

How to implement a driver cam?

Post by Hirogen »

I would like to have a camera that acts as the driver of a vehicle.
This means it shall follow an object and also mirror its rotation, but the camera should stay movable. For an example it should be possible to "walk" beside the object, but when the object rotates the camera should change its position and rotate, that the object is still seen from the same side.
The object which is followed should always be on the same position on the screen, but not necessarily in the center.
When I make to camera a child of the object I would like to be followed, the position of the camera follows my object but not the target.
GameDude
Posts: 500
Joined: Thu May 24, 2007 12:24 am

Post by GameDude »

So doy you want the camera like inside the vehilce like in GTA where you can see from inside the car, but you want it to be more realistic, as you have complete control as to where you look?
Hirogen
Posts: 19
Joined: Tue May 29, 2007 5:55 am

Post by Hirogen »

Yes, that's it. I want the camera to look through the front window by default. But it should also be possible to look through the side window or to "sit" on the engine bonnet.
GameDude
Posts: 500
Joined: Thu May 24, 2007 12:24 am

Post by GameDude »

By sit do you mean when you can see through the window you are able to see through the windshield from insdie the car, thus being able to see the sterring wheel, front panel and other things that are inside the front of the car?

For a start you can use

Code: Select all

scene::CameraSceneNode();
This is just a basic start and then try different camera positions, I haven't really experminted with the camera functions yet. Or you could try this.

Code: Select all

scene::CameraSceneNodeFPS();
Put additonal code inside the ()'s. Although I'm not sure if setting it up like a First Person Shooter would be good, but you could try it.
olivehehe_03
Posts: 157
Joined: Tue Mar 20, 2007 8:30 am

Post by olivehehe_03 »

Like GameDude said, try using a ICameraSceneNode.

One other way you could do this would be to position the camera inside your car and then set the parent of the camera to the car so that the camera will follow the position and rotation of the car (since cameras don't really have rotation you might need to set the target of the camera to x units in front of the car). Then you'd need write some basic mouselook code so that the camera can look in whatever direction the player wants. Hope that helps.
Tell me what you cherish most. Give me the pleasure of taking it away.
Post Reply