Game Development Community

Player Roll (Y rotation)?

by Mike Treanor · in Torque Game Engine · 02/29/2008 (3:00 pm) · 0 replies

Hello,

I'm trying to allow to player to be able to 'roll' their point of view (perform a y axis rotation).

By the looks of it, the "GameConnection::getNextMove(Move &curMove)" function is reading values for roll from the globals $mvRollLeftSpeed, etc. By looking at the "Do the twist" resource (http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=6713) it seems like I can ust do the following to make roll work:

In player.cc in the Player::updateMove function I add this:
F32 r = move->roll; //move->roll seems to already be set by getNextMove in GameConnection
if (r > M_PI) r -= M_2PI;
mHead.y = mClampF(mHead.y + r,-mDataBlock->maxFreelookAngle,mDataBlock->maxFreelookAngle); //arbitraily bound mHead.y by maxFreeLookAngle

Then in player.cc in the Player::getMuzzleTransform function I do this:
if (mActionAnimation.action < PlayerData::NumTableActionAnims)
{
MatrixF pmat,xmat,ymat,zmat;
xmat.set(EulerF(mHead.x, 0, 0));
ymat.set(EulerF(0,mHead.y, 0));
zmat.set(EulerF(0, 0, mHead.z));
pmat.mul(zmat,xmat); //apply the z and x rotations
pmat.mul(pmat,ymat); //apply the y rotation

mat->mul(getTransform(), pmat);

...
}

This doesn't seem to work. If there somewhere that the mHead.y info is being clobbered or not being set/sent?

I previously posted this in the public forums and I think now I get that I should post source modifications there, so here it is again!

Thanks