[Solved] WallJump help for a platformer

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Cristian

Solved: Just adding a raycast2d to detect walls and not use the collider OnWall()

Starting a project both Unity and Godot has the same issue (my fault :smiley: ). My problem is, when I jump when I am touching a wall, then press jump, cuts/teleports to the next position. Doesn’t move smoothly.

I am using the State machine finite. If velocity.y < 0 (Jumping) and touching a wall, change to WallJump state

// In the Player.cs
// In the _PhysicsProcess() is velocity = moveandslide(velocity)
public void Movement() {
// Move LR
Vector2 tmp_v = new Vector2();
tmp_v.x = Input.GetActionStrength("Move_Right") - Input.GetActionStrength("Move_Left");

velocity.x = tmp_v.x * SPEED;
}


// In the WallJumpState.cs
void _PhysicsProcess(){

Movement(); // From Player.cs ----^

if (IsOnWall() && !IsOnFloor())
{
	wallSliding = true;
}
else
{
	wallSliding = false;
}
if (wallSliding)
{
	velocity.y = Mathf.Clamp(velocity.y, -500F, -30F); // Slow fall
}

// HERE IS MY PROBLEM:
if (wallSliding && Input.IsActionJustPressed("Button_A") )
{
    velocity.x = -velocity.x * 2; // HERE, doen't move smooth, it cuts/teleports to the next place.
    velocity.y = -JUMPFORCE;
}

if (!IsOnWall())
{
    return fall;
}
if (IsOnFloor())
{
    return idle;
}
}

this “gdscript”
https://www.youtube.com/watch?v=rOg6oKvjCEs

ramazan | 2022-08-27 08:56