My character which is controlled with KinematicBody2D is flying off / gain velocity when moving towards the edges.
Here the code that I'm using for movement:
public override void _PhysicsProcess(float delta)
velocity.y += gravityMagnitude * delta;
Vector2 snap = Vector2.Down;
velocity = MoveAndSlideWithSnap(velocity, snap, upDirection: Vector2.Up, stopOnSlope: true);
Here's a GIF showing my problem:
I don't want the character to fly off like that if possible.
I've already tried:
- Applying Physics Material to the platforms and changing friction.
- Changing the shape of the player collider.
Can someone help me?