Forward Jump
by Paul Clarke · in Torque Game Engine · 06/21/2009 (6:27 am) · 4 replies
I've been trying to modify jumping so that the player will move forward aswell vertical.
In Player::updateMove I found
// If we are facing into the surface jump up, otherwise
// jump away from surface.
F32 dot = mDot(pv,mJumpSurfaceNormal);
F32 impulse = mDataBlock->jumpForce / mMass;
if (dot <= 0.0f)
acc.z += mJumpSurfaceNormal.z * scaleZ * impulse * zSpeedScale;
else
{
acc.x += pv.x * impulse * dot;
acc.y += pv.y * impulse * dot;
acc.z += mJumpSurfaceNormal.z * scaleZ * impulse * zSpeedScale;
}
I tried adding acc.y += mJumpSurfaceNormal.z * scaleZ * impulse * zSpeedScale;, which makes the player move forward but only in one direction. I want to be able to jump forward in the direction that the player is facing.
I hope that makes sense I didn't really know how to explain it, I'm still kind of a noob at this so any help is appreciated.
In Player::updateMove I found
// If we are facing into the surface jump up, otherwise
// jump away from surface.
F32 dot = mDot(pv,mJumpSurfaceNormal);
F32 impulse = mDataBlock->jumpForce / mMass;
if (dot <= 0.0f)
acc.z += mJumpSurfaceNormal.z * scaleZ * impulse * zSpeedScale;
else
{
acc.x += pv.x * impulse * dot;
acc.y += pv.y * impulse * dot;
acc.z += mJumpSurfaceNormal.z * scaleZ * impulse * zSpeedScale;
}
I tried adding acc.y += mJumpSurfaceNormal.z * scaleZ * impulse * zSpeedScale;, which makes the player move forward but only in one direction. I want to be able to jump forward in the direction that the player is facing.
I hope that makes sense I didn't really know how to explain it, I'm still kind of a noob at this so any help is appreciated.
About the author
#2
Update: It might be %player.getTransform
This thread may help;
www.garagegames.com/community/forums/viewthread/34470
06/22/2009 (7:35 am)
Don't know if this will work, but my first thought is to try something like %player.getRotation to get which way the player is facing.Update: It might be %player.getTransform
This thread may help;
www.garagegames.com/community/forums/viewthread/34470
#3
06/22/2009 (11:53 am)
We're in code, not script, so the %player syntax doesn't apply. But Tony has the right idea, you'll probably want to get the player's forward vector and add it to the jump direction. When you get a MatrixF from the getTransform method, I think column 0 is the forward vector. Try it out - call getTransform, getColumn, and add the vector you get. Experiment with the effect that adding different columns of the matrix gives you.
#4
Daniel, I just quickly tried your suggestion and it works almost perfectly, the only problem I have is that the player only jumps forward a small distance. I'll look into this later when I've got some spare time and hopefully I'll be able to sort it out.
Thanks again for the help.
06/23/2009 (4:15 am)
Thanks for the help guys.Daniel, I just quickly tried your suggestion and it works almost perfectly, the only problem I have is that the player only jumps forward a small distance. I'll look into this later when I've got some spare time and hopefully I'll be able to sort it out.
Thanks again for the help.
Torque 3D Owner Aleksander Elvemo