FPSCamera rotates when changing position?!

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
user-r3
Posts: 70
Joined: Tue Dec 07, 2010 4:09 pm

FPSCamera rotates when changing position?!

Post by user-r3 »

Ahoy!

First of all: Please execuse me, if this question is dumb or easy to solve or whatever, it is just, that I sat there for several hours yesterday and today, staring at my code, thinking with closed eyes, not finding out, what the problem really is, or how to solve it...

The camera is set up as follows:
There is a mesh attached to a irrbullet rigidbody - moving around
each frame the camera gets moved to the mesh (with a certain offset, for being at the head)
then the mesh is being rotated to fit the cam's rotation.

Nothing is parent or child of each other here...

However, when I am moving to the left (by giving the mesh a leftward velocity) the camera rotates to the left.
same applies for all other movement directions.

My first thought was, that the target of the cam (rotation and target are binded) stays the same, thus the movement leads to a rotation - this would, however, according to the picture in my head lead to rotation in the opposite direction of the movement, not the same dir. as it is the case with my problem...


When I look straight up or down, it even leads to my mesh turning in a small circle...

What could cause this problem/how could I solve it?

Thanks for any help in advance, if you need any code, just ask specifically for what you need in order to help me.

Thanks,
a desperate userrr3
CuteAlien
Admin
Posts: 9927
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: FPSCamera rotates when changing position?!

Post by CuteAlien »

Having a camera following the mesh - this just doesn't sound like a use-case for the fps-camera to me (as there you would move the camera and have the mesh follow). You might be better off writing your own camera-animator in such a situation.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
dmb
Posts: 9
Joined: Thu Jun 13, 2013 2:07 pm

Re: FPSCamera rotates when changing position?!

Post by dmb »

CuteAlien wrote:Having a camera following the mesh - this just doesn't sound like a use-case for the fps-camera to me (as there you would move the camera and have the mesh follow). You might be better off writing your own camera-animator in such a situation.
Can you use the animator to have a response based on user input?

PS sorry for hijacking your thread.
CuteAlien
Admin
Posts: 9927
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: FPSCamera rotates when changing position?!

Post by CuteAlien »

Yes you can do that. Set ICameraSceneNode::setInputReceiverEnabled to true and I think isEventReceiverEnabled of your animator also must return true.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
user-r3
Posts: 70
Joined: Tue Dec 07, 2010 4:09 pm

Re: FPSCamera rotates when changing position?!

Post by user-r3 »

CuteAlien wrote:Having a camera following the mesh - this just doesn't sound like a use-case for the fps-camera to me (as there you would move the camera and have the mesh follow). You might be better off writing your own camera-animator in such a situation.
Hello, first of all I'm sorry... I somehow solved the problem with some intense hours of trial and error... However, I have no idea what finally solved the problem.. :oops:

Thanks for your help anyways! May I ask, what disadvantages I have, when using the fpscamera (with movement speed 0) compared to a maually written camera animator for rotation?

Thanks again :)
CuteAlien
Admin
Posts: 9927
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: FPSCamera rotates when changing position?!

Post by CuteAlien »

As long as it works you are fine I guess :-)
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply