nodeBP is an actor which I want to move with the keyboard i.e. I do not want forces to apply on it in order to move it. Therefore I tried it in a simple way (by not using bullet's character controller or kinematic bodies / thanks ChaiRuiPeng anyway

).
The steering needs to be local, 'W' always forward 'S' backwards and so on.
Therefore my movement function is ('W' - forward)
- Code: Select all
m_position = vector3df(0.f,0.f,2.f);
m_position.Z +=m_speed*m_frameDeltaTime;
node->getAbsoluteTransformation.transformVect(m_position);
nodeBP->setPosition(m_position);
I cannot use nodeBP because CIrrBPConvexHullBody does not have the needed function.
No need to setPosition for Irrlicht node as I wrote in my 2. post, it is updated automatically.
when I rotate the (physics)Body in a way
- Code: Select all
m_degree = 2.f*m_speed*m_frameDeltaTime;
nodeBP->setRotation(nodeBP->getRotation()+vector3df(0.f, m_degree, 0.f));
I got a gimbal lock
If i write
- Code: Select all
m_degree = 2.f*m_speed*m_frameDeltaTime;
m_rotation = node->getRotation()+vector3df(0.f, m_degree, 0.f));
nodeBP->setRotation(m_rotation);
which I thought it is the same,
I do not get gimbal lock. Note that I am
using Irrlicht node to retrieve and calculate the rotation vector and then rotate the physics body (nodeBP), otherwise I get a gimbal lock
Again no need to setRotation to Irrlicht node, it is updated.
So use Irrlicht node to retrieve and calculate the rotation vector, store it in a variable and aply it then to the physics body nodeBP.
THX for suggestions, helped me clean up my code
