英文:
Why is the Area2D sprite overlapping the ground in my Godot game and how do I resolve it?
问题
最近我安装了Godot并决定制作一款游戏,但出现了一个问题:
我为角色添加了Area2D用于碰撞检测,但Area2D的精灵有点奇怪,因为它与地面重叠,见图:
看,它重叠了
请解决
请解决,这非常重要
对于@TheJalfireKnight
英文:
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
答案1
得分: 0
这是一个建议:我假设您正在为角色使用物理体(CharacterBody、StaticBody等)。如果您只想要碰撞,以防止它穿过地面,只需将碰撞形状添加为角色的子级,就像这样:
玩家
|
--Sprite2D
|
--CollisionShape2D
另外,向编辑器中发送场景的截图可能会有所帮助。也许碰撞形状设置不正确?
编辑:很抱歉我回复晚了。原因是像那样自定义碰撞检测并不可靠。我建议将玩家设为CharacterBody3D/KinematicBody3D,并将碰撞形状作为其父级。这样它会自动处理碰撞。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论