Flying character

uberglitch

04-11-2007 06:37:04

Hey folks, I apologize if my search-fu is weak on this, but I couldn't find a previous thread talking about it.

In my current project I have some Characters that can fly, now that I've got them immune to gravity I need a way of changing their pitch (local rotation about X) so that DR_Forward movements can involve a bit of up or down.

What I'm currently trying is to set the character's 3D rotation with a Quaternion:

(in MouseMoved)
if(isFlying){
Ogre::Quaternion q = player->getGlobalOrientation();
Ogre::Quaternion r = Quaternion(mPitch += Ogre::Radian(mMouseSensitivity * evt.state.Y.rel), Vector3::UNIT_X);
player->setDirection(q * r);
}


This code attempts to pitch the character up and down based on the Y movements of the mouse, so that but I feel like there's something fundamental I might be missing.

If it helps, here is the movement controller I'm using for the player:


class PlayerMovementController : public NxOgre::CharacterMovementVectorController {

public:

void move(NxVec3 &out, NxVec3 &moveVector, NxQuat &direction, NxVec3 &g, float t, NxOgre::Character*) {
if(flying)
out = (direction.rot(moveVector) * mySpeed) * t;
else
out = ((direction.rot(moveVector) * mySpeed) + g) * t;
}

void setFlying(bool fly) { flying = fly; };
bool isFlying() { return flying; }

void setMoveSpeed(NxReal speed) { mySpeed = speed; }
NxReal getMoveSpeed() { return mySpeed; }

bool flying;
NxReal mySpeed;
};


Thanks in advance,
Uberglitch

betajaen

04-11-2007 10:29:39

It don't think it's possible in the current character system, the new one you can though.

How about using a kinematic Actor, and use actor->moveGlobalPosition()/moveGlobalOrientation() instead?

uberglitch

06-11-2007 03:25:53

Thanks betajaen, since my deliverable date isn't until May '08 I think I'll just wait until the new character system is released and see if I can get things sorted at that point :)