Area2D精灵在我的Godot游戏中与地面重叠,如何解决?

huangapple go评论76阅读模式
英文:

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

Here You Go

答案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.

huangapple
  • 本文由 发表于 2023年5月26日 16:25:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/76338992.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定