Top down shooter ..using Vehicle instead of player
by Terence Tan · in Torque Game Engine · 05/16/2006 (7:58 am) · 4 replies
Hi,
Been mucking around with Torque for the last few weeks, trying to get things working on a prototype.
Right now we are working on a top-down shooter prototype and figured out the camera etc etc.
Been thinking a bit about how to do the character. Right now we are using w as up(of the screen), s as down ..d as right etc etc. We do want to keep the facing of the character though...so instead of the whole player to run up...if the player is facing down and you hit up..the player would run backward .
If the mouse acts as a targetting reticle..if the mouse moves ..the player upper torso would rotate left to right but still keep running up( or what ever direction they player is moving the player at the time).
So the player torso really more like tank turrent more than anything else right now...so I was wonder if anybody had any advice on how to approach this technical...been debating hacking up the player avatar..but think its a poor idea...and right now thinking of treating the player as a vehicle really.
The biggest issues I can visually see the legs going crazy like?...solvable by moving the camera up a bit (it's right now in a slightly higher 3/4 view)..the legs would be all the wrong way..or worse the character would seem to 'float' like he's on one of those tron discs...
Thoughts? Ponderings? Suggestions?
Been mucking around with Torque for the last few weeks, trying to get things working on a prototype.
Right now we are working on a top-down shooter prototype and figured out the camera etc etc.
Been thinking a bit about how to do the character. Right now we are using w as up(of the screen), s as down ..d as right etc etc. We do want to keep the facing of the character though...so instead of the whole player to run up...if the player is facing down and you hit up..the player would run backward .
If the mouse acts as a targetting reticle..if the mouse moves ..the player upper torso would rotate left to right but still keep running up( or what ever direction they player is moving the player at the time).
So the player torso really more like tank turrent more than anything else right now...so I was wonder if anybody had any advice on how to approach this technical...been debating hacking up the player avatar..but think its a poor idea...and right now thinking of treating the player as a vehicle really.
The biggest issues I can visually see the legs going crazy like?...solvable by moving the camera up a bit (it's right now in a slightly higher 3/4 view)..the legs would be all the wrong way..or worse the character would seem to 'float' like he's on one of those tron discs...
Thoughts? Ponderings? Suggestions?
About the author
#2
That would mean we have to do the changes on this resource? Probably think we have throw it out or at least change it to conform. Probably better done in the engine too because it should be called fairly often and involve re-calculations.
More or less what you are suggestion is keeping the player torso aligned to the mouse pointer...so if you rotate the mouse around the player the entire body would turn. You would then calculate the directional vectors based on where the mouse is and the key that the player presses. ( I think?)
05/17/2006 (8:56 pm)
Hmm...I vaguely understand what you mean....We would have to open up the camera code...right now we implemented Corey Osborn resource :http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5474 on Seperate cameras That would mean we have to do the changes on this resource? Probably think we have throw it out or at least change it to conform. Probably better done in the engine too because it should be called fairly often and involve re-calculations.
More or less what you are suggestion is keeping the player torso aligned to the mouse pointer...so if you rotate the mouse around the player the entire body would turn. You would then calculate the directional vectors based on where the mouse is and the key that the player presses. ( I think?)
#3
To gameConnectionMoves.cc add the following in "bool GameConnection::getNextMove(Move &curMove)"
after
Not sure if this is the best way to do it but it works. When the character is running towards you sometimes its seems a bit sluggish...I have to check the offsets.
05/24/2006 (12:41 am)
For anybody that cares, I sorta implement what I was looking for by adding the following code to the engine:To gameConnectionMoves.cc add the following in "bool GameConnection::getNextMove(Move &curMove)"
after
for(U32 i = 0; i < MaxTriggerKeys; i++)
{
curMove.trigger[i] = false;
if(MoveManager::mTriggerCount[i] & 1)
curMove.trigger[i] = true;
else if(!(MoveManager::mPrevTriggerCount[i] & 1) && MoveManager::mPrevTriggerCount[i] != MoveManager::mTriggerCount[i])
curMove.trigger[i] = true;
MoveManager::mPrevTriggerCount[i] = MoveManager::mTriggerCount[i];
}
// ***************************
// * Code added to use absolute movement with
// * respect to camera.
if (!mFirstPerson && mControlObject && mCameraObject &&
(curMove.x || curMove.y))
{
// get camera transform from object to world space
MatrixF camTrans = mCameraObject->getRenderTransform();
// Set vector movement to what the user has input
VectorF dirVec;
dirVec.x = curMove.x;
dirVec.y = curMove.y;
dirVec.z = curMove.z;
// transform to camera to world space
VectorF dirTransVec;
camTrans.mulV(dirVec,&dirTransVec);
// Get controlling object(player avatar) transformation
MatrixF conTrans = mControlObject->getWorldTransform();
// transform world space of camera vector to object space of control object
VectorF conTransVec;
conTrans.mulV(dirTransVec, &conTransVec);
// Put results back into movement
curMove.x = conTransVec.x;
curMove.y = conTransVec.y;
curMove.z = conTransVec.z;
}Not sure if this is the best way to do it but it works. When the character is running towards you sometimes its seems a bit sluggish...I have to check the offsets.
#4
05/28/2006 (5:04 am)
I think I fixed the sluggishness..it was because way I was using the camera too transform things would cause problems..especially with the camera direction...I check Cory Osborns resource on how to zero out axis ...I'm still trying to figure out why one of my friends says that after a while the 'Downward' movement gets slower...it's wierd...anybody see anything I'm not seeing...// *************************** Terence
// * Code added to use absolute movement with
// * respect to camera.
if (!mFirstPerson && mControlObject && mCameraObject &&
(curMove.x || curMove.y))
{
// get camera transform from object to world space
MatrixF camTrans = mCameraObject->getRenderTransform();
VectorF camF;
camTrans.getColumn(1, &camF);
// translate f,b,l,r (x,y) to rotational changes
// relative to the camera object
VectorF dirVec;
if (mFabs(camF.z) < M_SQRTHALF) {
dirVec = VectorF(curMove.x, curMove.y, 0);
} else {
dirVec = VectorF(curMove.x, 0, curMove.y);
}
// transform to camera to world space
VectorF dirTransVec;
camTrans.mulV(dirVec,&dirTransVec);
// Get controlling object(player avatar) transformation
MatrixF conTrans = mControlObject->getWorldTransform();
// transform world space of camera vector to object space of control object
VectorF conTransVec;
conTrans.mulV(dirTransVec, &conTransVec);
// Put results back into movement
curMove.x = conTransVec.x;
curMove.y = conTransVec.y;
curMove.z = conTransVec.z;
}
Associate Manoel Neto
Default Studio Name
So if the character is aiming to the right, and you press left, it walks backwards to screen left, if you press up, it strafes to it's left, moving up to the screen. So visually, it looks like you're watching a FPS match from above, with circle-strafing and such.