Wall Jumping in platformer
by Zachery Walsh · in Torque Game Builder · 06/14/2011 (8:43 pm) · 4 replies
Hey, i've been working on a platformer but i've been having trouble trying to implement wall jumping.
I want the wall jumping to be just like it is in Mega Man X for (super nintendo).
Here is a copy of the code i've been working on.
posted entire code here:
http://www.pastie.org/2070356
---------------------------------------------
Here is the section im talking about
---------------------------------------------
//-------- WALL JUMP TRUE ------------------------
if($wallJump == true)
{
if ( $moveLeft == true)
{
//make player move down slowly
player.setConstantForceY(55);
//player.setLinearVelocityY(100);
if ($jump == true)
{
//make player jump up
player.setLinearVelocityY($moveStatWallJump);
//make player move right
player.setlinearvelocityX($moveStatRight);
$jump = false;
$wallJump = false;
}
$moveLeft = false;
}
if ( $moveRight == true)
{
//make player move down slowly
player.setConstantForceY(10);
//player.setLinearVelocityY(100);
if ($jump == true)
{
//make player jump up
player.setLinearVelocityY($moveStatWallJump);
//make player move right
player.setlinearvelocityX($moveStatLeft);
$jump = false;
$wallJump = false;
}
$moveRight = false;
}
//$wallJump = false;
}
//-------- WALL JUMP FALSE ----------------------
if($wallJump == false)
{
//restore constant force Y
player.setConstantForceY($moveForceStat);
if ( $moveLeft == true)
{
//make player move left
player.setlinearvelocityX($moveStatLeft);
$moveLeft = false;
}
if ( $moveRight == true)
{
//make player move right
player.setlinearvelocityX($moveStatRight);
$moveRight = false;
}
if ( $jump == true)
{
// restore constant force;
player.setConstantForceY($moveForceStat);
if (player.getLinearVelocityY() == 0)
{
//make player jump
player.setlinearvelocityY($moveStatJump);
//reset constant force Y
//player.setConstantForceY(55);
}
//
$jump = false;
}
}
I want the wall jumping to be just like it is in Mega Man X for (super nintendo).
Here is a copy of the code i've been working on.
posted entire code here:
http://www.pastie.org/2070356
---------------------------------------------
Here is the section im talking about
---------------------------------------------
//-------- WALL JUMP TRUE ------------------------
if($wallJump == true)
{
if ( $moveLeft == true)
{
//make player move down slowly
player.setConstantForceY(55);
//player.setLinearVelocityY(100);
if ($jump == true)
{
//make player jump up
player.setLinearVelocityY($moveStatWallJump);
//make player move right
player.setlinearvelocityX($moveStatRight);
$jump = false;
$wallJump = false;
}
$moveLeft = false;
}
if ( $moveRight == true)
{
//make player move down slowly
player.setConstantForceY(10);
//player.setLinearVelocityY(100);
if ($jump == true)
{
//make player jump up
player.setLinearVelocityY($moveStatWallJump);
//make player move right
player.setlinearvelocityX($moveStatLeft);
$jump = false;
$wallJump = false;
}
$moveRight = false;
}
//$wallJump = false;
}
//-------- WALL JUMP FALSE ----------------------
if($wallJump == false)
{
//restore constant force Y
player.setConstantForceY($moveForceStat);
if ( $moveLeft == true)
{
//make player move left
player.setlinearvelocityX($moveStatLeft);
$moveLeft = false;
}
if ( $moveRight == true)
{
//make player move right
player.setlinearvelocityX($moveStatRight);
$moveRight = false;
}
if ( $jump == true)
{
// restore constant force;
player.setConstantForceY($moveForceStat);
if (player.getLinearVelocityY() == 0)
{
//make player jump
player.setlinearvelocityY($moveStatJump);
//reset constant force Y
//player.setConstantForceY(55);
}
//
$jump = false;
}
}
About the author
Game Design Student Artist / Half Descent Programmer
#2
But its not responding... also it seems like when i walk in the trigger my physics becomes strange? why is this?
06/19/2011 (10:47 pm)
Well im trying to use triggers to trigger the wallJump boolean.But its not responding... also it seems like when i walk in the trigger my physics becomes strange? why is this?
#3
06/28/2011 (12:06 pm)
Sometimes your physics might become "strange" because the trigger can call your collision functions over and over again depending on your collision settings and weather you are using the onStay function of the trigger. If you are still having trouble with this you can send me your code or We can screen share with skype and bonk our heads togeather?
#4
Wall jumping like in this: www.garagegames.com/community/blogs/view/15746
I'll make source available if you dig it.
06/29/2011 (12:20 pm)
Zachery,Wall jumping like in this: www.garagegames.com/community/blogs/view/15746
I'll make source available if you dig it.
Torque Owner Nic Biondi
Default Studio Name
It looks like you have the basic idea.. you need to reduce your gravity as you push into the wall then set it back to normal after you are not pressing into the wall.
-nic