I have found no tutorials concerning wall jumping, I am developing a 2d game, and it would be great to have a wall jump function. what would a ideal script be. https://playcanvas.com/editor/scene/1032540
Down below is the script I am using, please reply if you have a script that allows to wall jump
var from = this.entity.getPosition();
var to = new pc.Vec3(from.x, from.y - this.entity.getLocalScale().y, from.z);
var canJump = false;
var result = this.app.systems.rigidbody.raycastFirst(from, to);
if(result)
{
canJump = true;
}
else
{
canJump = false;
}
if(this.app.keyboard.wasPressed(pc.KEY_W) && canJump)
{
this.entity.rigidbody.applyImpulse(0,1000,0);
}
};
I have found no tutorials concerning wall jumping, I am developing a 2d game, and it would be great to have a wall jump function. what would a ideal script be. https://playcanvas.com/editor/scene/1032540
here is the code I have
//Jumping
var from = this.entity.getPosition();
var to = new pc.Vec3(from.x, from.y - this.entity.getLocalScale().y, from.z);
var canJump = false;
var result = this.app.systems.rigidbody.raycastFirst(from, to);
if(result)
{
canJump = true;
}
else
{
canJump = false;
}
if(this.app.keyboard.wasPressed(pc.KEY_W) && canJump)
{
this.entity.rigidbody.applyImpulse(0,1200,0);
}
I have posted several times. I am still looking for a wall jumping script
. I have already tried to tweak the code, it only makes it jump higher…
I am still new to the game engine, and java script. although I am slowly learning https://playcanvas.com/editor/scene/1032540
here is the code
var to = new pc.Vec3(from.x, from.y - this.entity.getLocalScale().y, from.z);
var canJump = false;
var result = this.app.systems.rigidbody.raycastFirst(from, to);
if(result)
{
canJump = true;
}
else
{
canJump = false;
}
if(this.app.keyboard.wasPressed(pc.KEY_W) && canJump)
{
this.entity.rigidbody.applyImpulse(0,1200,0);
}
Hello @Yes_Boi! Can you explain a little better what you want the wall jump to look like? With the current code you only check whether there is an obstacle on the bottom. With a wall jump you also have to check if there is an obstacle in the front. However, I am not a wall jump expert.
Greetings @Albertos well, A ideal wall jump would be where you can always jump when you are in contact with a wall or the ground, for example you would be able to jump from wall 1 if it is located at (0, 10, 0) to wall 2 that is located at (5, 15, 0)
Okay, then I would make a second raycast forward. If it has a result (so there is a wall) and the raycast down has no result (so the character is in the air) then I would turn my character 180 degrees and repeat the jump action.