Locking a camera's movement on one axis

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
pepeshka
Posts: 29
Joined: Wed Jul 02, 2008 8:42 pm

Locking a camera's movement on one axis

Post by pepeshka »

Hi all,

I'm working on a project where I want to lock an FPScamera on a single axis (I want no vertical movement). Turning off the vert movement bool in the constructor works to a point, but I've found that the camera can still move vertically via the collision system (for example, walking up a ramp). Is there any way to absolutely lock the camera in the engine so that it will never move along a defined axis?
Scarabol
Posts: 167
Joined: Sat Jan 03, 2009 5:26 pm
Location: Aachen, Germany

Post by Scarabol »

just add something like

Code: Select all

vector3df target = camera->getPosition();
target.Y = 0;
camera->setPosition(target);
to your while (device->run()) loop

MfG
Scarabol
Irrlicht 1.7.2
Eclipse
Boost
Xaryl
Posts: 90
Joined: Sat Apr 30, 2011 11:54 pm

Post by Xaryl »

I don't think that would work well though, because OnAnimate is called right before rendering.
pepeshka
Posts: 29
Joined: Wed Jul 02, 2008 8:42 pm

Post by pepeshka »

Scarabol wrote:just add something like

Code: Select all

vector3df target = camera->getPosition();
target.Y = 0;
camera->setPosition(target);
to your while (device->run()) loop

MfG
Scarabol
Well that's what I'm trying now, but the camera ends up getting stuck in the geometry. I think what happens is the camera moves a bit in the Y direction (just one "step" up a ramp, for example), then gets set back down to Y=0, which is inside the geometry.
Scarabol
Posts: 167
Joined: Sat Jan 03, 2009 5:26 pm
Location: Aachen, Germany

Post by Scarabol »

ok, sorry but in this case you could take a look at the irrlicht source, on how it works inside...

Im sorry i dont have the time.

MfG
Scarabol
Irrlicht 1.7.2
Eclipse
Boost
Post Reply