Godot Version
Godot 4.2.2
Question
I am making a game where the player moves a ball, a RigidBody2D, by changing the direction of gravity. However, the ball has a tendency to get stuck to walls, especially in corners, and I can’t figure out why. I’ve tried many different permutations of bounciness, roughness, and friction on both the walls and the ball; reducing friction helps but doesn’t entirely solve the issue. The ball has a circular collision shape (though I tried changing it to a square and it still gets stuck) and the walls are StaticBody2Ds. I’ve attached the relevant code of the gravity controller, an Area2D with SpaceOverride set to Replace covering the entire map. There’s essentially no other code in the project at the moment, so I’m very confused by this. I’ve also attached a gif of the issue. If anyone could help me with this it would be enormously appreciated.
extends Area2D
var grav = Vector2.DOWN
func _physics_process(delta):
if Input.is_action_just_pressed("grav_down"):
grav = Vector2.DOWN
if Input.is_action_just_pressed("grav_up"):
grav = Vector2.UP
if Input.is_action_just_pressed("grav_left"):
grav = Vector2.LEFT
if Input.is_action_just_pressed("grav_right"):
grav = Vector2.RIGHT
gravity_direction = grav