Godot引擎与KinematicBody的碰撞不起作用

我正在摆弄Godot引擎并尝试了一个小游戏.

但我似乎无法获得有关碰撞的信息.

if is_colliding():
    print ("Collision with " + get_collider())
    get_node("Sprite").set_texture(walk_cycle_right_1)
    move_state_right = 1
    set_pos(Vector2(get_pos().x -10, get_pos().y))

它总是打印错误.我正在使用set_pos命令移动我的角色(KinematicBody2d – > Sprite / CollisionShape2d).

最佳答案 对于运动体,您需要使用move或move_to来触发碰撞.

如果您确实需要使用set_pos,请检查collisionshape2d.shape并自行进行碰撞检查.

Goot文档中有一个示例,其中介绍了KinematicBody2D运动和碰撞处理:http://docs.godotengine.org/en/stable/tutorials/2d/kinematic_character_2d.html

Godot Documentation还提供KinematicBody2D类的完整定义:
http://docs.godotengine.org/en/stable/classes/class_kinematicbody2d.html?highlight=KinematicBody2D

点赞