与raycast2d碰撞在tilemaps上
我试图在Godot制作一个简单的2D采矿游戏。我需要让Raycast2D定位瓷砖,但它只是忽略了它们,因此即使脚本的开始也无法正常工作。 我检查了一下,启用了Raycast并朝着正确的方向查看。 这是我用来检查Raycast是否碰撞的脚本。
func tile_finding():
if is_colliding():
print("ok")
I'm trying to make a simple 2D mining game in godot. I need to make RayCast2D to locate tiles but it just ignores them, so even the start of the script isn't working.
I checked, raycast is enabled and looking in the right direction.
Here is the script I use to check if raycast collides.
func tile_finding():
if is_colliding():
print("ok")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要将碰撞形状连接到您有兴趣检查碰撞的每个图块(在瓷砖集面板中)。接下来,他们需要共享相同的碰撞层。您是否启用了raycast2d设置
启用
属性?使用TILEMAP的碰撞处理使用这样的代码:
You need to attach a collision shape to each tile (in the tileset panel) you are interested in checking collision with. Next they need to share the same collision layer. have you enabled the raycast2D setting the
enabled
property?the collision handling using tilemap uses code like this: