可以在Godot中移动Kinematicbody2d
我是Godot的新手,正在尝试将Kinematicbody2D沿X轴移动,但我无法做到。这是代码:
extends KinematicBody2D
func _physics_process(delta):
var velocity=Vector2(300, 0)
move_and_slide(velocity)
我认为此功能(_PHYSICS_PROCESS)并未以某种方式调用或触发。
I am new to Godot and am trying to move a KinematicBody2D along the x axis, but I am not being able to. Here is the code:
extends KinematicBody2D
func _physics_process(delta):
var velocity=Vector2(300, 0)
move_and_slide(velocity)
I think that this function(_physics_process) is not being called or triggered somehow.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在Godot 2中,我们有
_Process
和_fixed_process
,因此要做的第一件事是将_PHYSICS_PROCESS
更改为_FIXED_FIXED_PROCESS
。其次,默认情况下不启用它。因此,您应该调用
set_fixed_process(true)
启用它。像这样:In Godot 2 we had
_process
and_fixed_process
, so the first thing to do is to change_physics_process
to_fixed_process
.And second, it is not enabled by default. So you should call
set_fixed_process(true)
to enable it. Like this:也许下一个可以帮助您:
set_physics_process(false)
,或者对Kinematic脚本执行此操作。Maybe the next can help you:
sync to physics
of KinematicBody2D in the inspector is disabled.set_physics_process(false)
inside your script or another one that do this to the kinematic script.