Godot Version
4.2.2
Question
hello i am trying to sync a variable named “test” and here is my code that i tried
it works like this, gets updates for every peer in multiplayer:
@rpc("any_peer","call_local","reliable")
func testcheck():
test +=1
func _physics_process(_delta):
rpc("testcheck")
print(test)
when i press the input “yes” on two peers the “test” variable goes from 2 because i pressed “yes” input one time on both peers
BUT when i try to call “testcheck” in if condition it only updates locally like this:
var cond : bool = true
@rpc("any_peer","call_local","reliable")
func testcheck():
test +=1
func _physics_process(_delta):
if Input.is_action_just_pressed("yes") && cond:
rpc("testcheck")
print(test)
when i press the input “yes” on two peers the “test” variable goes from 0 to 1 each of the peers but it must show 2 instead of two 1
so on conclusion the first code sets “test” variable for every peer on multiplayer if test is increased by 5 it is 5 on every peer
but on second code it updates the “test” variable locally even if i call from rpc()
what am i doing wrong? the value needs to be updated when conditions met. thank you