character rotation & position reset

aida

13-08-2007 10:04:38

hi
I 've tried many solutions that I found in the forum to rotate my character correctly, but he always ends up by bouncing or jumping or rotating non stop.
So I eventually decided to rotate it without using force. The problem I'm facing now is that once I've moved without using force, if I use a force afterwards my position gets reset. Why?

Please help me, I've posted several messages with no luck, I'm really stuck.

Thank you

aida

14-08-2007 16:22:42

I eventually found a solution, not very clean, but the best way I found to get a smooth character movement. Really simple :

To move forward/backward :
Add the force

force2 = (Vector3(acel.x,gravity,acel.z))*mass;

with
Ogre::Vector3 V0 = me->getVelocity();
Ogre::Vector3 V1 = orient * mDirection;
Ogre::Real deltatime = me->getWorld()->getTimeStep();
Vector3 acel ((V1 - V0) / deltatime);


To rotate :

if(mRotX > (Radian)0){
me->setOmega(Vector3(0,1,0));
}else if(mRotX < (Radian)0){
me->setOmega(Vector3(0,-1,0));
}

To stop rotation :
me->setOmega(Vector3::ZERO);

in the KeyReleased method.