StateSynchronizer
Inherits: Node
Synchronizes state from authority.
Description
Similar to Godot's MultiplayerSynchronizer, but is tied to the network tick loop. Works well with TickInterpolator.
Tutorials
Properties
| Type | Name | Default |
|---|---|---|
| Node | root | |
| String[] | properties | |
| int | full_state_interval | 24 |
| int | diff_ack_interval | 0 |
| PeerVisibilityFilter | visibility_filter | new() |
Methods
| Return Type | Name |
|---|---|
| void | process_settings() |
| void | add_state(Variant node, String property) |
| void | set_schema(Dictionary schema) |
| void | merge_schema(Dictionary schema) |
| void | clear_schema() |
Property Descriptions
Node root
The root node for resolving node paths in properties.
String[] properties
Properties to record and broadcast.
int full_state_interval = 24
Ticks to wait between sending full states.
If set to 0, full states will never be sent. If set to 1, only full states will be sent. If set higher, full states will be sent regularly, but not for every tick.
Only considered if _NetworkRollback.enable_diff_states is true.
int diff_ack_interval = 0
No description provided.
PeerVisibilityFilter visibility_filter = new()
Decides which peers will receive updates
Method Descriptions
void process_settings ( )
Process settings.
Call this after any change to configuration.
void add_state ( Variant node, String property )
Add a state property.
Settings will be automatically updated. The node may be a string or NodePath pointing to a node, or an actual Node instance. If the given property is already tracked, this method does nothing.
void set_schema ( Dictionary schema )
Set the schema for transmitting properties over the network.
The schema must be a dictionary, with the keys being property path strings, and the values are the associated NetworkSchemaSerializer objects. Properties are interpreted relative to the root node. Properties not specified in the schema will use a generic fallback serializer. By using the right serializer for the right property, bandwidth usage can be lowered.
See NetworkSchemas for many common serializers.
Example:
state_synchronizer.set_schema({
":transform": NetworkSchemas.transform3f32(),
":velocity": NetworkSchemas.vec3f32()
})
void merge_schema ( Dictionary schema )
Add serializers from schema.
See set_schema() for specifying schema. As opposed to set_schema(), this method updates the schema, instead of overriding it. If a property had a serializer specified previously, this will replace it.
void clear_schema ( )
Clear any serializers specified earlier.
See set_schema().