I am making a 2d game in unity and I haven’t touched a game engine in months but I found this movement script I had saved which I wrote a while ago, I set everything up and when I was going to try, my wall jump was off. Instead of just going up diagonaly up and sideways like every wall jump mine simply goes to the side at a very not intended fast speed. I really can’t recall if this script was working back then but I dont think I would save something that doesnt work
private Vector2 wallJumpingPower = new Vector2(10f, 20f);
private float wallJumpDirection;
if (IsWalled()) //the isWalled() method is working
{
wallJumpDirection = -transform.localScale.x;
WallJump();
wallSlide();
}
private void WallJump()
{
if (Input.GetButtonDown("Jump"))
{
rb.velocity = new Vector2(wallJumpingPower.x * wallJumpDirection, wallJumpingPower.y);
}
}
private void wallSlide()
{
rb.velocity = new Vector2(rb.velocity.x, -0.4f); //this is the wall slide and it works
if (hasDoubleJumped)
{
canDoubleJump = true; //this is irrelevant
}
}
Ruben is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.