Page 1 of 1

Locking a camera's movement on one axis

Posted: Thu May 19, 2011 8:27 pm
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?

Posted: Fri May 20, 2011 2:41 pm
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

Posted: Fri May 20, 2011 3:05 pm
by Xaryl
I don't think that would work well though, because OnAnimate is called right before rendering.

Posted: Mon May 23, 2011 8:46 pm
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.

Posted: Mon May 30, 2011 2:32 pm
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