我正在尝试设置所有僵化的'速度为0,然后是以前的速度
因此,在过去的几个小时中,我一直在尝试创建一个暂停菜单。但是,我无法弄清楚如何阻止刚体移动。如果有一种方法可以立即停止所有僵化的机构,请告诉我,如果没有,我可以将其设置在每个脚本上,都用刚性的身体设置。到目前为止,这是我的代码:
extends Position3D
onready var charCamera = get_viewport().get_camera()
##var direction = Camera.global_transform.basis.get_euler()
signal spawned(spawn)
export(PackedScene) var spawnling_scene
var linear_velocity_on_pause = 0
var not_paused_anymore = false
var paused = false
#var Popup1 = self.get_parent().get_parent().get_parent().get_node("Popup")
func _physics_process(_delta):
if self.get_parent().get_parent().get_parent().get_node("Popup").visible == false:
if Input.is_action_pressed("leftClick"):
spawn()
if paused == true:
not_paused_anymore = true
paused = false
if self.get_parent().get_parent().get_parent().get_node("Popup").visible == true:
linear_velocity_on_pause = spawnling_scene.instance().linear_velocity
paused = true
spawnling_scene.instance().set_mode(1)
spawnling_scene.instance().linear_velocity = get_parent().get_parent().get_parent().get_node("LinearVelocityOf0").linear_velocity
if not_paused_anymore == true:
spawnling_scene.instance().set_mode(0)
spawnling_scene.instance().linear_velocity = linear_velocity_on_pause
not_paused_anymore = false
func spawn():
var spawnling = spawnling_scene.instance()
spawnling.linear_velocity = charCamera.global_transform.basis.z * -100
#spawnling.global_transform.basis = charCamera.global_transform.basis
add_child(spawnling)
spawnling.set_as_toplevel(true)
emit_signal("spawned", spawnling)
##insert pause system
return spawnling
##var spawnling = spawnling_scene.instance()
##
## add_child(spawnling)
## spawnling.set_as_toplevel(true)
So I have been trying to create a pause menu for the past few hours. However, I cannot figure out how to stop the rigidbodies from moving. If there is a way to stop all rigidbodies at once, please tell me, if not, I can set it to each and every script with a rigid body. Here is my code so far:
extends Position3D
onready var charCamera = get_viewport().get_camera()
##var direction = Camera.global_transform.basis.get_euler()
signal spawned(spawn)
export(PackedScene) var spawnling_scene
var linear_velocity_on_pause = 0
var not_paused_anymore = false
var paused = false
#var Popup1 = self.get_parent().get_parent().get_parent().get_node("Popup")
func _physics_process(_delta):
if self.get_parent().get_parent().get_parent().get_node("Popup").visible == false:
if Input.is_action_pressed("leftClick"):
spawn()
if paused == true:
not_paused_anymore = true
paused = false
if self.get_parent().get_parent().get_parent().get_node("Popup").visible == true:
linear_velocity_on_pause = spawnling_scene.instance().linear_velocity
paused = true
spawnling_scene.instance().set_mode(1)
spawnling_scene.instance().linear_velocity = get_parent().get_parent().get_parent().get_node("LinearVelocityOf0").linear_velocity
if not_paused_anymore == true:
spawnling_scene.instance().set_mode(0)
spawnling_scene.instance().linear_velocity = linear_velocity_on_pause
not_paused_anymore = false
func spawn():
var spawnling = spawnling_scene.instance()
spawnling.linear_velocity = charCamera.global_transform.basis.z * -100
#spawnling.global_transform.basis = charCamera.global_transform.basis
add_child(spawnling)
spawnling.set_as_toplevel(true)
emit_signal("spawned", spawnling)
##insert pause system
return spawnling
##var spawnling = spawnling_scene.instance()
##
## add_child(spawnling)
## spawnling.set_as_toplevel(true)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不是在回答如何将所有刚体的速度设置为零的问题。
您想制作暂停菜单,这就是您应该知道的:
如果 您可以使用这样的使用来暂停:
和恢复:
请参阅。
哪个
节点
s在get_tree()。暂停
设置为true
依赖其pape_mode
属性时。默认情况下,它们都将停止,但是如果您将其pape_mode
设置为pape_mode_process
,当get_tree()时,他们将继续工作。
true
。这就是您要使用Node
构成您的暂停菜单UI的方法。但是,该系统不会暂停着色器。他们的
时间
将继续打勾。如果要“冻结”着色器,则可以将0设置为按这样的时间缩放:将其设置为
1
,以定为正常速度:您可以设置其他值以使它们放慢速度或加速。
说到放缓和加快。如果您想在游戏的其余部分(不仅仅是着色器)这样做,则可以使用
Engine.time_scale
。而且,如果您不想受到影响,则必须在os
类中使用时间函数编写它。I'm not answering the question of how to set the velocity of all rigid bodies to zero.
If you want to make a pause menu, this is what you should know:
Godot has a puse system, which you can use like this to pause:
And to resume:
See Pausing Games.
Which
Node
s gets to execute whenget_tree().paused
is set totrue
depend on theirpause_mode
property. By default they will all stop, but if you set theirpause_mode
toPAUSE_MODE_PROCESS
they will continue to work whenget_tree().paused
is set totrue
. And that is what you want to do with theNode
that make up your pause menu UI.However, that system will not pause shaders. Their
TIME
will continue to tick. If you want to "freeze" shaders you can set a 0 to their time scaling like this:Set it to
1
for normal speed:And you can set other values to have them slow down or speed up.
Speaking of slow down and speed up. If you want to do that for the rest of the game (not just shaders), you can use
Engine.time_scale
. And if there is some timing that you don't want to be affected, you would have to write it using the time functions in theOS
class.