This is a bit of a short one but I'm working on a multiplayer game and I've been using the multiplayer synchronizer node, but some things just don't appear for other players such as particles or the transition period of an animation, I'm just wondering if my understanding of the node is incorrect or if I'm just using it wrong
This will have to be dealt with by syncing the appropriate state that will trigger the particle and animation events. Also the use of MultiplayerSpawner nodes should be used in conjunction with MultiplayerSynchronizer nodes. There is also the concept of authority, which guide the direction of data flow, as its most appropriate that there is only one source of truth. i.e. only one synchronizer will send data to all peers. so if you change something on a non-authorized node, it will not sync to other peers.
In general a MultiplayerSynchronizer will only pass the properties you assign it to sync with remote instances from the authority. It is then up to you to write the proper logic to react to changes to the data. In the end i would say to your final statement:
So just to make sure I understand, rather than me syncing Sprite:animation it would be syncing the function that causes the animation to change or particles to spawn? If so how would I go about doing that if that’s easy to explain at all?
Also I have been using the multiplayer spawner and MSC.get_multiplayer_authority() in my scripts with MSC being: @onready var MSC = $MultiplayerSynchronizer but I really appreciate the advice
I wouldn’t sync animations at all, I would sync the state that activates the animation. This is easier if you use an AnimationTree with a state machine node. but if you call functions that activate an animation, you probably should consider refactoring.
consider crouching, this is activated by input. Input is sent to the player authority (the server). Authority applies input and activates the player_state = crouch. The authority sends player_state to all remote instances. all instances have synced player_state. An AnimationTree sees player_state == crouch and sets the appropriate animation.
Oh perfect! I am using a State Machine for my players, I had no idea there was a way to sync a full node? when I click on the node it just comes up with 5 options, 4 of them being process related and the last being editor_description, is it one of the processes or do I need to do something to the node first?
In the animationtree there is an AnimationNodeStateMachine resource and there is a concept of the expression node, within each transition arrow you create you can define an condition to traverse to the next animation state.
This isnt syncing the node but reacting to data that is synchronized. Again you will need to write your code to follow this pattern.
In my example sprite2d will have a variable player_state and enum crouch that will be checked every frame by the animation tree state machine. If that condition becomes true then it will transition into the crouch animation. This allows you to sync one int variable player_state to trigger animations on remote instances.
extends Sprite2D
@export var player_state:int
enum {
none,
crouch
}
func _unhandled_input(event):
if event.is_action("crouch"):
if event.pressed:
player_state = crouch
else:
player_state = none
func _physics_process(delta):
# do crouch stuff
Okay now I’m really confused, my animated sprite just suddenly started working without me doing much with the animation player? It must’ve been something pretty simple Regardless, Yay!
But now I still have the problem with it not syncing anything instantiated like a projectile or particle effect, how would I go about doing that? thank you so much for your help so far!
I would probably not sync particles at all but make sure the logic that exercises the particles get triggered with any state changes.
If the particle is part of an animation, animations can call methods that spawn particles. If particle is part of a collision just allow the local collision to generate the particle. Etc.