How do i make the player stop when colliding with a wall?

Godot Version



i have a AnimatedSprite2d with a collisionPolygon2d attached. in the Area2d, i have another collisionPolygon2d on part of the map i don’t want the player to go to. but when i play, the player goes right through the collisionPolygon. I’ve also tried adding hitboxes to the tiles but that didn’t work either. I am new to Godot and don’t know how to code at all, please help.

use characterbody2d instead as a base, and put the animated sprite 2d and collision shape as a child in it, that’s how you make it can collide with physics objects. area2d with collision only detects whether something is entered or exit, not for collision