Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | mdswamp |
hi guys…
after joining 2 players in the lobby, we pause the scene tree. then we call the pause menu (the bottom code is the pause menu script). i want to sync scenes of 2 players, so when each player press the pause button, game should start. the problem is that i dont know how to send and set a variable in each scene (p1_pressed belongs to server and should be true and send it to the client and p2_pressed belongs to client and should be true and send it to the server)
when i run the game with this script, when i press pause button in server scene, in debugger p1_pressed set to “true” and p2_pressed set to “false” and when i press pause button in client scene, in debugger p1_pressed set to “false” and p2_pressed set to “true”. each scene seems send nothing to each other, how should i fix this?
Any help or guidance would be greatly appreciated
p.s: this is a one on one fighting game
extends Panel
onready var waiting = get_node("Waiting")
onready var count_down = get_tree().get_root().get_node("PvP/CountDown")
onready var counter = get_tree().get_root().get_node("PvP/CountDown/Counter")
onready var counter_animation = get_tree().get_root().get_node("PvP/CountDown/CounterAnimation")
onready var counter_timer = get_tree().get_root().get_node("PvP/CountDown/CounterTimer")
var p1_pressed
var p2_pressed
func _on_Paused_pressed():
waiting.show()
p1_pressed = false
p2_pressed = false
if get_tree().is_network_server():
p1_pressed = true
rset("p1_pressed", true)
after_post_pressed()
else:
p2_pressed = true
rset("p2_pressed", true)
after_post_pressed()
func after_post_pressed():
print(p1_pressed)
print(p2_pressed)
if p1_pressed == true && p2_pressed == true:
self.hide()
count_down.show()
counter_animation.play("CountDown")
counter_timer.start()
func _on_CounterTimer_timeout():
count_down.hide()
get_tree().set_pause(false)