操作系统或设备 - Godot 版本:
Windows 10 x64 - Godot 2.1.2.stable.official
问题描述:
使用 move() 移动 KinematicBody2D 后,不会更新 Collider 变换。
每一步都只会测试初始对撞机的位置/变换。
重现步骤:
func _ready():
set_fixed_process(true)
func _fixed_process(delta):
move(Vector2(0, 100))
move(Vector2(100, 0))
set_fixed_process(false)
A 只会向下移动,但不会向右移动。
即使在向下移动之后,A 也会适合 B。
它应该在 B 下方并且应该以 L 形移动(先向下,然后向右)。
移动不会将碰撞器更新到新位置,因此在尝试向右移动时,它似乎被 B 挡住了,就像我们只向右移动一样。
解决方法:
将 _fixed_process 更改为:
func _fixed_process(delta):
move(Vector2(0, 100))
var st = get_shape_transform(0) # get current shape transform, assuming we only have 1 shape
st.o += get_travel() # add move translation to shape transform
set_shape_transform(0, st) # update shape transform
move(Vector2(100, 0))
# you should reset the shape transform to its original state befor returing
set_fixed_process(false)
我认为这是#7951 的副本,但我希望@RandomShaper确认:笑脸:
是的,这是同一个问题。
我错过了那个。
谢谢。
最有用的评论
我认为这是#7951 的副本,但我希望@RandomShaper确认:笑脸: