public override void _PhysicsProcess(float delta) { velocity.x = 0; velocity.y += Overlord.STANDARD_GRAVITY; if (parent.TestMove(parent.Transform, velocity) && !parent.TestMove(parent.Transform, new Vector2(speed * 5 * (int)direction, velocity.y)) ) { direction = direction == WalkingDirection.Left ? WalkingDirection.Right : WalkingDirection.Left; changeDirection((int)direction); } velocity.x = speed * (int)direction; var collision = parent.MoveAndSlide(velocity); if (Math.Abs(collision.x) < speed) { direction = direction == WalkingDirection.Left ? WalkingDirection.Right : WalkingDirection.Left; changeDirection((int)direction); } if (collision.y == 0) { velocity.y = 0; } }