Character setDirection [with video!]

dbrock

19-01-2008 05:43:35

I've been playing around with the Character class for just about the entire day now, and so far I have a moving character which reacts very well with my scene. The next step is rotating the character along the Y axis (spinning).

I'm doing that with the following code
if(mInputHandler->isKeyDown( OIS::KC_I) )
{
chester->addMovement( Character::DR_Forward );
}

if(mInputHandler->isKeyDown( OIS::KC_K ) )
{
chester->addMovement( Character::DR_Backward );
}

if(mInputHandler->isKeyDown( OIS::KC_L ) )
{
chester->addMovement( Character::DR_StepLeft );
}

if(mInputHandler->isKeyDown( OIS::KC_J ) )
{
chester->addMovement( Character::DR_StepRight );
}

OIS::MouseState ms = mInputHandler->getMouseState();
int relX = ms.X.rel;
if( relX != 0 )
{
Quaternion q;
q.FromAngleAxis( -Radian( relX * 0.15 * deltaTime ), chester->getGlobalOrientation() * Vector3::UNIT_Y );
q = q * chester->getGlobalOrientation();
chester->setDirection( q );
chester->addMovement( Character::DR_None );
}


The character only wants to spin while I'm moving.

The video can be viewed by going here: http://deadcold.smallchangestudios.net/movie.wmv

Is there any way around this?

betajaen

19-01-2008 10:17:12

Interesting and nice movie (nice to see Cake fairing up after this time).

Anyway, the NxCharacter itself never actually rotates, it just moves in a directional vector, but the node does. I'm thinking that the code that deals with the node rotation isn't working, or you have a strange setup to make the character not rotate it.

Also before you do anything drastic. Take out this line and see what happens:-

chester->addMovement( Character::DR_None );

yuriythebest

19-01-2008 14:11:18

dead link on the video

dbrock

19-01-2008 16:21:51

Try saving it rather then streaming it, I just tried it again, and it worked for me.

Actually, I tried to spin without that DR_None code, I figured it would update if I through it in, but it didn't. I could try rotating the node though, I just don't want it to do one of those 180 turns back to the old position when I start moving again.

BonD

19-01-2008 22:58:44

I'm using this code in my 3rd person chasing camera system.
// Rotate the character as mouse moves
const OIS::MouseState ms = mouse->getMouseState();
mMainNode->yaw(Radian(Degree(-ms.X.rel * 0.15).valueRadians()));
mCharacter->setDirection(mMainNode->getOrientation());


Where mMainNode is the Character's node.

Hope this helps.

dbrock

20-01-2008 01:08:48

I'm using this code in my 3rd person chasing camera system.
// Rotate the character as mouse moves
const OIS::MouseState ms = mouse->getMouseState();
mMainNode->yaw(Radian(Degree(-ms.X.rel * 0.15).valueRadians()));
mCharacter->setDirection(mMainNode->getOrientation());


Where mMainNode is the Character's node.

Hope this helps.


Thanks! This actually worked ^.^

chester->getNode()->yaw( -Radian( Degree( relX * 0.15 ).valueRadians() ) );
chester->setDirection( chester->getNode()->getOrientation() );