Fixed netcode

This commit is contained in:
Rendo 2025-11-26 16:51:39 +05:00
commit 1c062489b1
2 changed files with 4 additions and 11 deletions

View file

@ -9,10 +9,11 @@ func _ready() -> void:
for child in get_children():
if child is State:
states[child.name] = child
child.transition.connect(on_transition_required)
child.transition.connect(on_transition_required.rpc)
else:
push_warning("Child of state machine is not state")
@rpc("authority","call_local","reliable")
func on_transition_required(to: StringName):
if states.has(to) == false:
push_warning("Incorrect state request: " + to)
@ -25,8 +26,6 @@ func change_state(to_state: State) -> void:
current_state.exit()
current_state = to_state
current_state.enter()
update_remote_machines.rpc(to_state.name)
@rpc("authority","call_local","unreliable")
func clear_state():
@ -35,13 +34,6 @@ func clear_state():
current_state.exit()
current_state = null
@rpc("authority","call_remote","unreliable")
func update_remote_machines(to: StringName) -> void:
if current_state != null:
current_state.exit()
current_state = states[to]
current_state.enter()
func _process(delta: float) -> void:
if current_state == null:
return