Replicated Properties
Replicated properties are variables whose values are automatically synchronized across the network, from the server to all clients. UnrealSharp allows you to easily define which properties should be replicated and under what conditions.
Declaring Replicated Properties
To declare a property as replicated, annotate it with the [UProperty] attribute and set the PropertyFlags.Replicated flag:
Using OnRep Functions
For more control over replication, you can specify a callback function that the multiplayer system will call when a replicated property changes. This is particularly useful for updating game state or UI in response to property changes.
OnRep Function with Old Value
If you need to know the previous value of a property, you can define an OnRep function that takes the old value as a parameter:
Lifetime Conditions
Sometimes, you might want to replicate a property only under specific conditions, such as only to the owning player. You can achieve this by specifying a LifetimeCondition:
Last updated