You're using an Area2D
, so you're going to detect contact, but not collision. You seem to be using the area_enter
signal, so that should trigger when the Player's area detects another Area2D
entering. Is your print statement firing?
If it is, and you do detect the contact, now you have to create a response. You would have to shift the player's position to the appropriate edge of the wall.
In all honesty, this is an overly difficult way to do this. You can get the desired behavior with a minimal amount of code by using KinematicBody2D
for your Player, and StaticBody2D
for your walls.