Setting the movement speed for a character

fassihi

30-12-2007 04:38:46

I would like to set the movement speed for a character controlled by the user.
I am using the CharacterController class. What would be the best place to implement this speed value?

Currently the move method is used from the CharacerController class and it is hard coded.

fzh

30-12-2007 06:16:15

class myMovement : public NxOgre::CharacterMovementVectorController
{
public:
void move(NxVec3 &out, NxVec3 &moveVector, NxQuat &direction, NxVec3 &g, float t, NxOgre::Character* )
{

NxReal mySpeed = 50;
out = ((direction.rot(moveVector) * mySpeed) + g) * t;
}

};



overwrite the move function in charactermovementvectorcontrollier class by inheriting it, and set the speed in there.

myMovement *movement = new myMovement;
mCharacter->setMovementVectorController(movement);


then set your character's controller to the overwritten movement class.

fassihi

30-12-2007 15:28:08

Very nice, thanks a lot!