- Edited
This is what I tried.
puppet var food = 10
func addfood():
food += 20
func calc_food():
rpc("sync_food")
remotesync func sync_food():
rset("food", food)
$Foodcounter.text = str(food)
func _on_Button_pressed():
addfood()
calc_food()
What happens is it works fine. Except the first time I press it the client has 10 Food, and the server has 30 food. After that every time I press the button there is a 20 food discrepancy.
I'm assuming the information is sent before the addfood() func has run and that's why the server is always ahead by 20 food, but I can't figure out how to solve this.
Also, if there is an easy way to just code. client food = server food .
Then let me know.