Hello, this is Youngho Lee
We'll learn about actor replication in this unit
It is the most important concept for Unreal Engine network
First, we will learn property replication
For this, we'll make a test actor
and learn how to register the actor's replication option and owner
Then, we'll learn how to sync its
rotation and color on the network
Next is RPC
We'll learn what RPC is and its operation structure
and use this to sync materials' color values
First, let's learn property replication
Property replication
Property replication literally means replicating properties
Property means member variable
For this, I'll first make a C++ class
Select C++ class and right click
and choose new C++ class
Here, I'll choose actor
and next
put the name as NetActor
Then create class
Then it opens on Visual Studio
When this pop up shows up, load it and open it
then go back to Unreal Editor
and make NetActor as a blueprint and use it
Right click NetActor
and click on create blueprint class
Blueprint in the NetTPS folder
We'll save it there
I'll name it BP_NetActor
Click on create blueprint class
and then we'll work with this blueprint class
by adding a static mesh component
Go to NetActor header file
and on the very bottom add 'public new property'
as visible anywhere
Then class UStaticMeshComponent
and meshComp
Move to constructor function from header
and here, we'll make a meshComp
meshComp = CreateDefaultSubObject
and put UStaticMeshComponent here
then TEXT Mesh Comp
And then we'll put this MeshComponent as RootComponent
Like this
Then the size
Let's make this StaticMeshComponent a bit smaller
by half
We have SetRelativeScale3D on meshComp
We'll put FVector here and set it as 0.5
Then the scale of this Static MeshComponent
will be set as 0.5
Build and
we'll turn off Unreal editor and turn it back on
Unreal editor is on. From blueprint holder
double click on NetActor to open it
Here you can see that meshComp is in here
but there's nothing here right now
so it doesn't show on the view port window
We'll register the static mesh that we'll use here
There's static mesh on the detail window on the right
We'll search sm_ball here as the static mesh that we'll use
Select on sm ball 01 and you'll see this
Good
This is the static mesh that's on this one
and when you click on compile
you can see that the material is also assigned like this
Then we'll put this BP NetActor
and see if this shows on owner setting on the screen properly
We'll go on and check that
We'll add the part that outputs information on network state
Come to Visual Studio
and to NetActor.header file
We'll add a function that outputs information on the very bottom
We'll add void PrintNetLog
Create implementation
We'll do that on NetActor.cpp
We'll also add a PrintLog calling code on tick
On PrintNetLog
we'll put the same that that did the information outputting on the player
Go to NetTPSCharacter and there's PrintLog
Take everything there
and we'll put it here on NetActor.cpp
There are no roles for local and remote
so let's add them to include
#include and add NetTPS.h here
Then it'll all be in there with no errors
Header file on the top
Let's add the part that includes
First let's build
and once that's done, go to Unreal editor
and put NetActor.cpp
Take blueprint NetActor.cpp
and put it here with drag and drop
Out player is there
Let's put it here so that we can see it from a bit closer
And maybe a bit higher here
Let's play it and see
Then on this NetActor.cpp it shows the current state
It shows the information on network
Let's add a client
and check it there as well
When you do that, on the server
Local Role is set as ROLE authority
This exists in the server and Remote Role
says ROLE none
It means that remote is not there right now
On the client state as well
local role is none and remote role is
authority, why?
Because the part that syncs the network
is not set yet
So we'll set the owner
and check these two parts now
Then I'll add the part that sets the owner
On the network connection structure
The structure itself, there's a client
and there's the server
For these two to communicate, what's necessary is
a PlayerController
The server as well
it needs a corresponding PlayerController that let's these communicate
So ultimately, saying that they communicate through PlayerControllers
Our character right now is a Pawn
This guy is communicating using the net connection in the PlayerController
The pawn is also using this to communicate
But the actor that we made, NetActor
is existent in both the server and the client
So there's no owner right now
It needs to communicate through this using the PlayerController
but this part is blocked right now
So we need that part the sets the owner
to build a communication structure
That way we can use the property replication
to sync the data
So, coming back to Visual Studio
we'll head to NetActor header file
We'll range check
and within this range, the closest
pawn will be set as the owner
So first, let's add a range variable
that can detect owner
Come to u property and to let it be editable on web
put it as edit anywhere
and then we'll put float search distance
Let's say about 2 meters
So when pawn comes within 2 meters
that will be set as the owner
Then let's move to tick function
On NetActor.cpp
let's put this on tick
Have the
closest pawn
as owner
When it is within range
Setting as the owner only when it's within the range that I'm checking
We'll put that logic
But there's one thing to keep in mind here
If you set it as owner in client, there's no meaning in that
Why?
All these logics are managed by who?
By the server
If the client says 'I wanna set this one as the owner'
but this does nothing
These things must be set at the server
so that the server does the managing and sets it as the owner
So the client party shouldn't take charge of this part
It has to be the server
Only in the server
Then what should the role be
LocalRole must be Authority
Only that way, we have the server
I told you that HasAuthority is the function that let's us know about that
Go to HasAuthority
and it checks and let's us know
if LocalRole is authority
Then it will be the server
So when this is the server, we'll do this
Right
And in this case, choose the closest one
and we're trying to set that actor as the pawn, the owner
To select that, we'll make AActor variable
newOwner
Make that one first
and then make a float minimum distance variable
and put an initial value for the search distance
within range
Then when it enters that range
it will start the search
and the one smaller than this one
will be the owner
Let's try it using for
Here, TActorIterator ANetTPSCharacter, I'll find that only from the world
The variable name is it, and put get world
Then on the world, ANetTPSCharacter will be the only one I'll check
Then when existent
increase the pointer like this
And the red line here
is because ANetTPSCharacter is not included
Another thing, to use this TActorIterator here
you need to add this EngineUtils.h
Like this, EngineUtils.h, then NetTPSCharacter.h
You need to add these two with #include
Coming back to tick
and repeat by finding ANetTPSCharacter
object and searching
First, but actor for temporary variable
and otherActor
Then let's put it
and float dist
There's this function called GetDistanceTo
and put otherActor here
It'll show give you the distance between the NetActor
and the otherActor
Then, if
dist is smaller than the min dist that we set above
Then what happens?
It's within the range
and also closer in the range
min dist is now updated as dist
then the minimum value is updated
Then on the newOwner that we had set above
we'll put the otherActor that we found
Like this, we can choose the close actor
It'll repeat that until the for statement ends
Then, here, under for, owner
Let's set owner once for statement has ended
It will have the closest ANetTPSCharacter type object
saved on newOwner
We'll set that one as the owner
only when GetOwner is not the same
because if they're the same, it doesn't need to be set again
That's not necessary
so we'll put newOwner in SetOwner
Then it will be updated when owner is different
When there's no owner it's null
So these two won't be the same and it will put it
So, finding the closest
actor and putting it
That was in the tick
Let's build and run
to see if owner properly gets updated
Let's play
Now, how does it look
You can see that it says NoOwner
Let's move forward, it's set as 2m
It says BPThirdPerson character_C_0 on the owner Name
Right? The ownerName is here
You can see that this part here is working properly
But this here doesn't show the boundary
so it's a bit hard to test
Let's visualize the boundary
Go to Visual Studio
and move to the very bottom of the tick function
Right under authority, a visualization code Boundary visualization
Let's use this one, DrawDebugSphere Put GetWorld
and then put the NetActor location value and around that
we'll draw a search circle
We want to draw a circle that's the size of the search distance
And the circle's segment is 30
FColor, let's have the color as yellow
and put false
Whether it will be maintained, we'll have that as false
and then for lifetime and priority, we'll put 0
It'll be 0, 0, 1
We'll have the line width of 1
Now let's run it
The boundary is showing now
If you enter this boundary, it is set
It's done
Let's also run a client
Great
When the client enters, what happens to the owner?
NoOwner, it's in the boundary
but still there is no owner set
It says NoOwner here
On the server, it shows the ownerName right
but to the client, it says NoOwner
The reason is this
in network, all actors like this
wants to communicate
It would be nice if that was automatic
but then there would be a big waste in data
So all the actors in here aren't synced
Even if the owner is set, only the ones that are picked to be synced
are synced in the network
That we will learn later on
For now
we didn't put the part that assigns this one to be synced in network
so it doesn't show up
That's about it
Let's just organize the functions a bit
There are too much stuff in the tick
so the code that we made for visualization
This part
I'll make a function and move it
On the NetActor header file
I'll make a function void FindOwner
and move it here
Here, from Has authority to boundary visualization
Ctrl+X, so there's only print net log on tick
We'll move them all to FindOwner
Tick only needs to call FindOwner
I'll move it like that
Then, for data synchronization
We call this replication
So let's work on that option
Go to NetActor cpp constructor function
and on the very bottom, we'll add network syncing option activation
We call this synchronization
Actor Replication, right
We're activating that
There's this thing called bReplicate
Have this as true
and now, this NetActor will automatically
sync in network
once owner is set
Right, let's build
We'll turn Unreal editor off and turn it back on
I'll do that just to be safe
Great
Let's play and test it
and also a client as well
Now, no matter the server or client, I'll enter the boundary
I'll do it on the server
When I do that, owner is set
and let's check it from the client
Check it from the client and how does it look
This makes it easier to see
You can see
that here, on OwnerName, BP ThirdPersonCharacter
is there
Here, BP ThirdPersonCharacter
You can check that it shows up
That means b-replication option is activated as true
so the network can be communicated
Right, and
what about local role?
Just now, it said role none
but now it says simulate proxy
This is made in the server and managed in the server
so on the client, it just simply says that
it's simulated
And the current owner is this
Good Then now, the NetActor in the network
has all the basic settings done for communication
We'll use this to sync the property value
First, we'll sync rotation
We'll make the NetActor here spin
and we'll make that be synced
between the server and client
Go to Visual Studio
and to sync rotation
we'll add a sync variable
Go to NetActor header file
and we'll add it on the very bottom
public, and we'll add a rotation value sync variable
UPROPERTY and
here, float, the rotation value
will be based on one axis
It won't be all the values on X, Y, Z
but just one
so that there is less data packet
So I'll put RotYaw here
in lower case, RotYaw
This is to sync the rotation Yaw value
Doing only this
will network sync all the data here
which will then
waste too much packets
So in property replication, the property member variable
that you're aiming to sync
These member variables need a certain option
What that is is you need this option in this UPROPERTY
You put the option value of Replicated
and then, this will be subject to network syncing
That's what this is saying
Then let's build
Then
you can see an error message
It says error link
and unverifiable external symbol and public virtual void
It says that the function GetLifetimeReplicatedProps is not implemented
This error because that is missing
We just need to implement that here
I'll take this part
and put it down here
GetLifetimeReplicatedProps
I'll put that here
and const, then this function is redefined
Here, super, on GetLifetimeReplicatedProps
I'll put this variable
Now finally, the implementation part for syncing RotYaw will go in
Here's where that goes
The function used here is do replicate lifetime
DOREPLIFETIME
Put ANetActor, source here
and then RotYaw
What happens?
The implementation that syncs this on network
is added here
Above net high, you need to include so that unreal network.hr can be used
Then we'll implement rotation value setting
for rotation syncing
Under find owner
we'll implement the part that does the rotation
Let's first make it rotate
How we do that is, there's this function add actor local rotation
It says add, so it's a function that keeps adding rotation value
We also have quaternion value
and you can also put rotator value as well
We'll put FRotator
and the value will be Pitch Yaw Role
so put Pitch Yaw Role
and we'll put vallue in the
parameter that says InYaw
Rotation speed will be 50 multiplied by
delta time
and pitch and role will be 0
Then it will rotate in this speed
Let's check if this part works first
It will rotate now
Let's check that
Click on the play button
and you can see that our blueprint NetActor is rotating
But let's see here
First check the one on the server
and then from the client
It seems that both are rotating well
But this part, strictly speaking
isn't rotating because it's network synced
Why?
It's just each of them rotating this actor
It's not that we want all clients to be rotating separately
but for them to be synced to the
rotation data value of the server
Right, so strictly speaking, this part is wrong
We need to make data on the server
and then make all clients rotate
with this data
So we'll work on this rotation part
by separating them to
server and client each
First, for server
Rotate
and then what
Rotation value
We'll remember that
Remembering rotation value data means
that this data will be sent to all clients
And when it's not the server
In that case, rotation synchronization with the rotation value
received from the server
Let's work on the server first
As I mentioned until now, for the server
it's the server if the if has authority function is true
Here, the code that rotates and remembers the value
will be in here
This is the rotation
and this will be the part that remembers the rotation value data
Here we have the RotYaw function
On that function
we'll take the rotation information of the
actor that's rotating right now
What value?
We'll put the Yaw value in
What we're trying to sync is this Yaw value
so we'll take that and sync it
Then the client, if not the server
it will be a client
Here, we said that we sync rotation using the rotation value from the server
That mean's that we'll put the RotYaw part on my rotation value
We'll take that and remember it
Frotator and newRot
Take the getActorRotation value
and save that
Then on the Yaw value of newRot
we'll put the RotYaw
that we got synced from the server
And on the setActorRotation value of the actor
we'll have newRot
Let's build and play
Then there
NetActor is rotating
and adding a client
we can see that it's rotating as well
Right? They are synced
in network
This is done automatically
in property replication
Very simple
But there's more to think here, why?
Tick can be called every frame, that is
60 times a second or 30, 60, or more than 100 times
Receiving data from the server every time is a problem on its own
but also the server will keep changing the data value
But even when it doesn't
Even when there's no change in the tick value
the tick function will continue to update the value
Right? We're wasting the CPU
Even when it's not receiving data from the network
tick will keep updating which is a problem
So it will be more efficient if
we have it be updated
only when the rotYaw value is changed
Let's learn that
Go to netActor.h on Unreal Engine
On the UPROPERTY option
it says replicated
We use not replicated but
a different option
I'll copy this and put it as annotation
I'll say Replicated using here
Then after that
I can register an event call back function
hat will be called when the rotYaw property value has changed
It's basically a promise
It starts with OnRep_
Put the variable name after that, RotYaw
and then the function with that name will be called
When the property rotYaw, the value changes
the function OnRep RotYaw will be called
Then this one will be registered like this on the engine
and be called automatically
so just function declaration isn't good
We need to put UFUNCTION Macro
for Unreal runtime to automatically call this one
void, and call
Let me implement this function
Great, OnRep Yaw. RotYaw
and I'll implement this one right under the tick function
Under here
Good
What we got from the server will be here, not here
If it's not the server, this doesn't need to be managed
Because if the rotYaw is changed
OnRep RotYaw is automatically called
Let's build
On tick, if the server, the value will be changed
and if client
the OnRep RotYaw function will be called
and this will be done automatically
Let's play it
and also a client
Then you can see that it rotates on the client as well
And the ones here registered on the property replication
How often will they be updated?
That's in here as a default option
On NetActor, you see this class default
Search net update here
and you'll see net update frequency
This is set as 100
Actors will by default, NetUpdateFrequency
will be called 100 times per second
and updated, that's the setting
Just because it's set as 100
doesn't mean that it will always do that
Depending on the network environment it could fall
or become 1
if it's very slow
But the default actor
is set to have the frequency of 100 times per second
So we change the data
it will be updated immediately
if the 100 frame stands, right?
But if, on network
there's too much latency
meaning that it lags
Then, the NetUpdateFrequency of
100 that's set here
might not work properly
Then it will have pauses
For example, let me change this NetUpdateFrequency
First close this, and on constructor, there's net duplicate
I'll change the NetUpdateFrequency to 1.0
and let's run it
Then, on server
I kept it to rotate at this speed
But client might have a problem here
That one's set to be updated only once a second
so on the client,
it will receive the changed event and be updated only once every second
Let's see how that looks
Let's play
On the server, you can see that it's rotating smoothly
Let's see from the client
How does it look
You can see that it's pausing, it's being updated just once every second
so it's trying to catch up the server value
It's being updated every second and pausing in between
Like this, the NetUpdateFrequency is set as 100
but that doesn't mean that all actors have the default of 100
Why? There are instances where 1 is enough every second
The game won't have much problem even if it's updated just once a second
So on game state classes
the net update is set to be just once
Depending on objects
the value might vary
But the basic actors like Pawn
and characters
are set on 100 by default
Next, let's sync the material and color
On begin play, we'll use a timer
to update it
And every time it is updated
the updated value will be received as event function
and from then on the clients will also
be synced
Go back to header file
and to sync the material color, make it public
and put material, color
First, UPROPERTY
class MaterialInstance
I'll put dynamic MaterialInstance
I'll put UMaterialInstanceDynamic
Then we'll name the variable mat
and have the color of the material that will be synced as a variable
This will be the property that we'll sync
UPROPERTY
and then I'll use ReplicatedUsing
Let's say the function name will go OnRep_
and ChangeMatColor
Then that means a function with this name will have to exist
Put FLinearColor, MatColor
Then we have to make the OnRep ChangeMatColor function
Add a UFUNCTION macro
and declare void here
Here, the variable to by synced, the property will be MatColor
and when this MatColor is changed, the function
OnRep ChangeMatColor will be called
Right? We'll add implementation on this one
and I'll move this under BeginPlay
to see if BeginPlay calls and it is synced properly
I'll move it here to do that
Great, now this option that on network
it wlil be synced is declared that
But we can't just declare this MatColor
but we also have to add this one to the definition part On the very bottom of NetActor
there's this function GetLifetimeReplicatedProps
Here, like rotYaw, matColor needs to be registered
Great, it must be registered
for this to be synced automatically when value changes on network
Good, now let's go to BeginPlay
In the beginning
to bring and put dynamic material instance, we'll put mat
and this mat
will have the 0th one of
CreateDynamicMaterialInstance
from meshComp on NetActor
Then we'll put the code that
works when the value is changed in this function
if mat
There will be setVectorParameterValue in mat
We have to put the parameter name here
How do we know this parameter is right here
The material the our NetActor is using is right here
Double click on this
and the material instance shows up here
The thing we want to change is this FloorColor
You see FloorColor here
There's also GlowColor but I'll change FloorColor only
I'll change the FloorColor which is grey right now
Come to Visual Studio and on setVectorParameterValue
The value we'll put in, the parameter will be text
and here, FloorColor
We're going to update this to matColor
Update to matColor
This function, onWrapChangeMatColor
is called when matColor is updated
This will change to the updated material color
Then we'll need a code that updates this
We'll make one using a timer on BeginPlay
The action of making the data that changes value
must be done where?
On the server
Action of making data, changing
It must be done in the server
Then we'll check if server, has authority
and we'll put the timer on
FTimerHandle. Handle
and GetWorldTimerManager, SetTimer
Put a handle here and FTimerDelegate
create Lambda, we'll use Lambda
Capture, annotate, and we'll do this
We'll put the needed values here
First, the matColor. We'll have to put values in
FLinearColor one by one
We'll have RandRange on FMath
and make it have a value between 0.0 and 0.3
We'll put RGB on X, Y, Z
We're going to copy this part and keep them the same
We'll make them three
And the last value will be 1, the alpha value
Then comma, 1
and we'll put true at the end
We're making it repeat the process
and this means to repeat every 1 second
Great, what we know from this is that every second
matColor will be updated repeatedly
If the matColor is updated, OnRep ChanheMatColor is called
and the clients will be synced to this value
Let's build and see
On the server, it's not updated
But on the client
you can see that it's being updated
The color changes only for the client
The reason is?
The server only changes the data
Right? It's not implementing it
OnRep event function only updates it
But on C++, how does this OnRep event function work?
It's called only on the clients
So only the clients' colors change
It's not calledo n the server so it doesn't change
So what do we do, how do we sync the server?
We'll have to call this function
so on the timer, we'll change matColor and
call it here
Let's build again
Now on the server as well, it's changing properly
On the client as well
How does it look?
You can see that they are synced and changing
This was property replication
RPC
Now we'll learn about RPC
RPC is the abbreviation of remote procedure call
and RPC is used
when you want to run a function on a remote
someone else's computer
This RPC is the only way for the client to express their opinion
Requests like asking the server to run the logic of
shooting a gun can be done with this RPC
Then to use RPC
let's talk about more detailed operation structure
RPC works in 3 ways
Server, client, and NetMulticast
First, the server is used to call a function in the server from the client
and the client is used to call a function in the client from the server
This applies to only one client
Lastly, NetMulticast, unlike client option I just mentioned
is used to call function in all clients from the server
For example, on chat
you can send a message you typed using server option to the server
and the server can again
send that to client option or NetMulticast option
To send it to just one client
use client option
and to send it to all users
you can use NetMulticast option
Looking at a diagram
you can understand how RPC works better
First, from the client
user sends a message to the server using server RPC option
This works by calling a function in the server
And when that function is called in the server
server processes the game's logic
and send the result to clients
using client RPC option or NetMulticast RPC option
This also works by calling each clients' functions
When the client function is called, the client
syncs to the data the the server sent
or updates the effect on the screen or UI
Unreal Engine uses this RPC
When a client receives an input
then it requests to the server
It sends a request
to the server
Then on the server, it processes a game logic
How will it request then
It uses RPC to request
It requests with RPC
and the server runs the logic and the result
is sent back to the client using property replication
or another RPC
to call a function in the client
RPC works in several ways
As you saw on the screen
there's server RPC where client sends to server
and there's one that server
sends to client, this was client to server
and this one is server to client
Here, there are two types
One is client RPC
and the other is NetMulticast
NetMulticast, this one
sends to just one client
But NetMulticast under here
sends to all clients
So this time, NetMulticast
client, and server RPC Using this RPC
we'll change the color value
Go to Visual Studio
and go to NetActor.h
Here, when matColor changes
this function is called automatically
We'll change this part using RPC
RPC will be here separately
UFUNCTION
To use RPC, put UFUNCTION and
have the option of serve, client, or NetMulticast
First, we make the server RPC
The server will request a client to change the color
Then the server will receive that and
send to all clients to change the color
Server, and there's another option
Here, reliable or unreliable
There are these two options
Reliable means trusting the data
The function I'm calling might be omitted on the network
But if it's reliable, it means that it will be ensured not to be omitted
Here, to make sure to change the color
we'll put reliable
void server, we use this like a promise
It could be used in different forms for different developers
but to let you know that it's an RPC function
it will be good to mention server RPC
We'll put ServerRPC_ChangeColor
const f linear
Color, renew color
Then let's work on this value
if mat, we'll
like OnRep ChangeMatColor
update to newColor
But there's something weird here right
We gave the function the name ServerRPC ChangeColor from the header
but on the cpp there's this _implimentaion thing
This is here because I used auto completion and why did this happen?
The function ServerRPC ChangeColor here on the original one
is saved in here generated h
And
it's implemented there
We are going to
internally make this function be called using this
_implementation
so to call the implementation of this function
this part is needed
Good?
So to make the server RPC function be called
Let's do that
Go up and as the timer on BeginPlay is called
the value will change and automatically call this
We'll make it call server RPC function here
So annotate this and ServerRPC_ChangeColor
You can also call the implementation function
but then it will only be called in the server
For the client to call the server
this will be better
And then I'll put matColor
This one is also syncing right here
on the header file
So to not change this value
I'll put FLinear color so that they're different
I'll make a separate local variable
Then the matColor in the property and this loval variable will be different
Great, then this function in the server will be called
Then ServerRPC ChangeColor function is called and then
sent to the server
After that this function will be automatically called
and this code will be run
Let's build
Let's see, play
You can see that it's changing properly
Let's play
with a client added
How does it look from the client
Is it changing properly
Nothing's changing, only the server is, why?
Because we're using server RPC
This is run only in the server
Server RPC means client requesting the server
So this code only runs in the server
Then we should make it be updated on the client
With a diagram, this is how it must work
Looking at this part here, client requested the server
Change the color, so the server changed the color
From server RPC
Then what should server RPC do?
I changed the color, update it
It should send that to the client and only then
the client can update it
So we shouldn't do this on the server
but on the client so that the clients can work on that separately
so we'll add client RPC
Here on the very bottom
we'll have UFUNCTION client
Let's say unreliable
This means that it can get omitted and not that it is omitted often or always
Omission doesn't happen often in the network
void ClientRPC, we'll put the name
_ChangeColor
Then const FlinearColor
newColor
Great, let's add implementation
We'll add implementation on netactor.cpp
That's this part on the server
This means that we'll make the client
change colors instead of the server
Then the server can call ClientRPC
Let's do that
ClientRPC, ChangeColor newColor
Then it will be communicated on network
How?
Client requests server RPC to server
Then the server again
runs a logic
which sends a client RPC back
Then the remote, client's
client RPC change color function will be called
Now let's build
Let's play it here
It's being called properly on the server
Right? We can see it
But run a client
and let's see
Does it work properly on the client?
No right? It is on the server
but on the client, it's not changing
But see what I'm going to do
I'll go in here into the boudary
and there's a owner now
The client has owner now
Here the OwnerName
shows BPThirdPersonCharacter in owner
Here, right?
On the NetActor, owner is here
because it's in here
The moment it enters here
they can network communicate
Then let's look and the server
Server's value isn't being updated
Right?
Now I'll go out
Now the client isn't updating and only the server is
The reason is, when there's no owner, look
There's no owner
then there can't be communication
Client asks the server to send something
and uses client RPC
Then the server, on client RPC
'I'll send that data to that client'
so this client RPC function was called
But then why isn't that working on the server?
This is a characteristic of this
client RPC option
It only sends to on client
so the server has a client
and the client also has its own client
But to only who from the server?
Just to that client so it only has this right now
Because this owner is the only one that can communicate
NetActor is now the owner
This is the only one that communicates
Then what should we do if we want all clients to update this data
We can use NetMulticast RPC instead of this
We'll use NetMulticast
Let's build and play again
It's changing properly on the server, and what about the client?
They're both changing properly
That wraps up until NetMulticast
and RPC
Let me summarize what we've learned on this unit
Property replication
Actor replication Method for Unreal network's sync
Member variable data syncing on property replication
Must use UPROPERTY (Replicated) Must register on GetLifetimeReplicatedProps function
Property value aimed to sync Can receive event from network when synced The event callback function must have OnRep_ in front
RPC What is RPC? Abbreviation of Remote Procedure Call Calling a remote function
Server RPC Used to send message from client to server
Client RPC Used to send message from server to client
NetMulticaste RPC Used to send message from server to all clients
The End