Player sticking to rigidbody2d

Godot Version

godot 4.0 stable


i am working on top down game and i need the player to push objects around
so i followed this tutorial
and it worked just fine until i tried pushing the object downwards, the player just sticks to as if gravity was involved but i have my default gravity set to zero
does anyone knows why that happens?

In order to make it remotely possible to help you need to provide some details, share your code, show gifs/videos of the problem.

Without it it’s just a guesswork. Anything can by the reason.

here is a video of the problem

this is the code for the player

extends CharacterBody2D

var push = 150

@export var speed = 175

func _physics_process(delta):
	if Input.is_action_pressed("move_right"):
	elif Input.is_action_pressed("move_left"):
	elif  Input.is_action_pressed("move_down"):
	elif Input.is_action_pressed("move_up"):
	else: $"default")
	for i in get_slide_collision_count():
		var c = get_slide_collision(i)
		if c .get_collider() is RigidBody2D:
			c.get_collider().apply_central_impulse(-c.get_normal() * speed)
func handleInput():
	var movedirection = Input.get_vector("move_left","move_right","move_up","move_down")
	velocity = movedirection * speed

Compared to the tutorial you are using your current velocity as a push force instead of push variable you have defined.

thats because i tried both and the problem was still present

Interesting. What your platform_floor_layers and platform_wall_layers are set to?

i actually dont know what that is :sweat_smile:

never ming i just found them they both are set to default
floor has all the layers selected
wall has none

hey man i just removed the floor layer that has the rigid body and it worked perfectly
thank you man just ended days of suffering

1 Like