Search code examples
collisiongodotgodot4

Why is the Area2D sprite overlapping the ground in my Godot game and how do I resolve it?


Recently I installed godot and decided to make a game but there was a problem: I added Area2d for character for collision detection but the area2d sprite is kind of sick because it is overlapping the ground see:

See it is over lapping Please solve

Please solve it is very important

For @TheJalfireKnight

Here You Go


Solution

  • Heres a suggestion: I am assuming you are using a physics body for the character (CharacterBody, StaticBody, ect.). If you just want collisions so it can't pass through the ground, just add a collision shape as the child of your character. Like this:

    Player
    |
    --Sprite2D
    |
    --CollisionShape2D
    

    Also it would be helpful to send a screenshot of your scene in the editor. Maybe the shape is wrong?

    EDIT: I'm sorry for the late response. The reason is having custom collision detection like that isn't reliable. I would make the player a CharacterBody3D/KinematicBody3D, and put a collision shape as a parent of that. It will automatically do collision.