Using Enums with RPC Channels

I did some testing because it seemed to work sometimes and not others.

Turns out storing the RPC_CHANNELs on an autoload doesn’t work on it’s own, since the rpc compiles(?) before the autoload exists. I was falling into the trap of the second example, so I made it into a class and that works.


On an autoload called GM which is a GAME_MANAGER class:
enum RPC_CHANNELS { TIME_SYNC = 7 }

results

:white_check_mark: Called from an rpc ON game manager - WORKS (prolly not the best practice)
@rpc ("authority", "call_local", "unreliable_ordered", RPC_CHANNELS.TIME_SYNC )

:x: Called from the autoload - DOES NOT WORK
@rpc ("authority", "call_local", "unreliable_ordered", GM.RPC_CHANNELS.TIME_SYNC )

:white_check_mark: Getting the enum from the game manager class - WORKS
@rpc ("authority", "call_local", "unreliable_ordered", GAME_MANAGER.RPC_CHANNELS.TIME_SYNC )

1 Like