Time for action – Checking the level's NetMode.
Let's change our AwesomeWeaponUpgrade
actor to check for our level's NetMode
.
Let's rewrite the
PostBeginPlay
function:simulated function PostBeginPlay() { `log("PostBeginPlay===================="); `log("NetMode:" @ WorldInfo.NetMode); }
Compile the code.
Now run the server and client. Let's see what shows up in the server's log:
[0019.97] ScriptLog: PostBeginPlay==================== [0019.97] ScriptLog: NetMode: NM_DedicatedServer
And now for the client:
[0013.26] ScriptLog: PostBeginPlay==================== [0013.26] ScriptLog: NetMode: NM_Client
What just happened?
So why don't we just use NetMode
instead of Role
and RemoteRole
? As a server, NetMode
can either be NM_DedicatedServer
or NM_ListenServer
, but Role
will always be ROLE_Authority
.
So when WOULD we use this? In the discussion of Role, one example we used was not spawning effects on the server. However, with NM_ListenServer
we WOULD want the effect to spawn, since the server is...