You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Godot中Area2D与木箱碰撞检测失效问题求助

2D游戏Player与木箱碰撞检测问题求助

我正在开发一款2D游戏,Player通过W键及鼠标控制移动(基于transform实现),但无法实现与木箱的碰撞检测。我给Player创建了Area2D节点,挂载了Sprite2D和矩形CollisionShape2D,但Player穿过木箱时无任何反应,已尝试多种方法,恳请协助解决。

代码示例

extends Area2D

# Called when the node enters the scene tree for the first time.
func _ready():
    pass # Replace with function body.

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
    pass

func _on_area_entered(area):
    if area.name == "Player":
        print("PLAYER ENTERED THE CRATE");

相关截图说明

  • 截图1:展示Area2D节点结构,包含Sprite2D和带有CollisionShape2D的子节点
  • 截图2:2D游戏视图,呈现Player与木箱在场景中的布局

内容的提问来源于stack exchange,提问作者Atomwiser

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.24 23:17:03