Jumping Forward
by Chris "C2" Byars · in Torque Game Engine · 06/13/2006 (6:39 pm) · 8 replies
Is there an easy way to modify the jump function to make you jump forward a distance as well as up, rather than straight up?
#2
On line 1563 (In TSE player.cpp, I don't have TGE here).
That's where you should start, in updateMove() and merely add to acc.y to get the effect you're looking for.
06/14/2006 (4:24 am)
To further explain what Manoel is talking about:On line 1563 (In TSE player.cpp, I don't have TGE here).
// Acceleration from Jumping
if (move->trigger[2] && !isMounted() && canJump())
{That's where you should start, in updateMove() and merely add to acc.y to get the effect you're looking for.
#3
To give you an idea, I'm making a game that revolves around the player movement being.. hopping. Hop forward, backward, side to side, rather than walking or running forward/back/sideways, so I'm working to find a way to get this to work. In script you can do it, its just the movement forces aren't very good paired with jumping, for good control/speed.
06/14/2006 (5:44 am)
Right around here, I assume.F32 dot = mDot(pv,mJumpSurfaceNormal);
F32 impulse = mDataBlock->jumpForce / mMass;
if (dot <= 0)
acc.z += mJumpSurfaceNormal.z * scaleZ * impulse * zSpeedScale;
else
{
acc.x += pv.x * impulse * dot;
[b]acc.y += pv.y * impulse * dot;[/b]
acc.z += mJumpSurfaceNormal.z * scaleZ * impulse * zSpeedScale;
}To give you an idea, I'm making a game that revolves around the player movement being.. hopping. Hop forward, backward, side to side, rather than walking or running forward/back/sideways, so I'm working to find a way to get this to work. In script you can do it, its just the movement forces aren't very good paired with jumping, for good control/speed.
#4
Jumping like you can jump in different directions in Unreal games?
06/14/2006 (6:27 am)
Try changing acc.y to use the same math as acc.z, and see what happens.Jumping like you can jump in different directions in Unreal games?
#5
I may implement the air control/jump direction resource, I think it might be what needs to be done to get the effect I wish to achieve.
06/14/2006 (6:30 am)
Doing the same math doesn't seem to do anything, or if it does, a very slight difference in direction when jumping on angled surfaces.I may implement the air control/jump direction resource, I think it might be what needs to be done to get the effect I wish to achieve.
#6
You shouldn't have to implement the air control resource, but good luck to you. :)
06/14/2006 (6:40 am)
It's just a matter of applying force in the Y direction.You shouldn't have to implement the air control resource, but good luck to you. :)
#7
Only one problem I'm having. I put the jump code into each of the movement functions. However, if you hold more than one movement button down at a time, the jump stops and you just run. What should I do to make it so if a movement key is already being held down, don't call the $mvTriggerCount2++; on the others?
06/14/2006 (11:02 am)
Edited: The air control resource + scripting should do everything I need. :)Only one problem I'm having. I put the jump code into each of the movement functions. However, if you hold more than one movement button down at a time, the jump stops and you just run. What should I do to make it so if a movement key is already being held down, don't call the $mvTriggerCount2++; on the others?
#8
Finally got it working flawlessly after working with a hell of a lot of if and else statements. Phew.
06/14/2006 (1:12 pm)
*rejoices after a ton of rewriting and testing*Finally got it working flawlessly after working with a hell of a lot of if and else statements. Phew.
$movementSpeed = 1; // m/s
$forwardy = "false";
$backwardy = "false";
$lefty = "false";
$righty = "false";
$isMoving = "false";
function setSpeed(%speed)
{
if(%speed)
$movementSpeed = %speed;
}
function moveleft(%val)
{
if (%val && $isMoving $= "false")
{
$mvLeftAction = %val * $movementSpeed;
$mvTriggerCount2++;
$isMoving = "true";
$lefty = "true";
}
else if (%val && $isMoving $= "true")
{
$mvLeftAction = %val * $movementSpeed;
$isMoving = "true";
$lefty = "true";
}
else if ($forwardy $= "false" && $righty $= "false" && $backwardy $= "false")
{
$mvLeftAction = %val * $movementSpeed;
$isMoving = "false";
$mvTriggerCount2++;
$lefty = "false";
}
else
{
$mvLeftAction = %val * $movementSpeed;
$lefty = "false";
}
}
function moveright(%val)
{
if (%val && $isMoving $= "false")
{
$mvRightAction = %val * $movementSpeed;
$mvTriggerCount2++;
$isMoving = "true";
$righty = "true";
}
else if (%val && $isMoving $= "true")
{
$mvRightAction = %val * $movementSpeed;
$isMoving = "true";
$righty = "true";
}
else if ($lefty $= "false" && $forwardy $= "false" && $backwardy $= "false")
{
$mvRightAction = %val * $movementSpeed;
$isMoving = "false";
$mvTriggerCount2++;
$righty = "false";
}
else
{
$mvRightAction = %val * $movementSpeed;
$righty = "false";
}
}
function moveforward(%val)
{
if (%val && $isMoving $= "false")
{
$mvForwardAction = %val * $movementSpeed;
$mvTriggerCount2++;
$isMoving = "true";
$forwardy = "true";
}
else if (%val && $isMoving $= "true")
{
$mvForwardAction = %val * $movementSpeed;
$isMoving = "true";
$forwardy = "true";
}
else if ($lefty $= "false" && $righty $= "false" && $backwardy $= "false")
{
$mvForwardAction = %val * $movementSpeed;
$isMoving = "false";
$mvTriggerCount2++;
$forwardy = "false";
}
else
{
$mvForwardAction = %val * $movementSpeed;
$forwardy = "false";
}
}
function movebackward(%val)
{
if (%val && $isMoving $= "false")
{
$mvBackwardAction = %val * $movementSpeed;
$mvTriggerCount2++;
$isMoving = "true";
$backwardy = "true";
}
else if (%val && $isMoving $= "true")
{
$mvBackwardAction = %val * $movementSpeed;
$isMoving = "true";
$backwardy = "true";
}
else if ($lefty $= "false" && $righty $= "false" && $forwardy $= "false")
{
$mvBackwardAction = %val * $movementSpeed;
$isMoving = "false";
$mvTriggerCount2++;
$backwardy = "false";
}
else
{
$mvBackwardAction = %val * $movementSpeed;
$backwardy = "false";
}
}
Associate Manoel Neto
Default Studio Name