I am decently new to Unreal and I am currently working on a personal project to create a multiplayer fps shooter. I am following a tutorial for most of it but I want to add something of my own and I am not sure how to go about it. I have four different platforms in the level that all raise and lower with random (within a range) up time and down times, syncing the movement across all players via a run on server custom event called at begin play and looping the run on server event.
But, the thing I cannot figure out is how to ensure that only one of the four platforms is up at a time. How to get a reference to each instance of the actor blueprint in the level and then check each and only raise a random one if all are down?
Thanks for the help in the advance and sorry if there is documentation I am missing. I’ve looked around though and can’t find what I need.
When it comes to networking, we must remember that “Server is King!”
Commands and execution calls should happen on the server and the corresponding actions will be replicated to the clients.
As for world objects communicating with each other. Event dispatchers (delegates) is a clean and optimal way to go about it.
One solution could be the following:
1 - Create an array in the GameMode to store references to each of the platforms.
2 - In the platform class, on Begin Play, store a self-reference to the array in the Game Mode.
(Now the Game Mode knows about all platforms).
3 - Set up an event dispatcher in the platform class and call it when the platform instance is raised.
4 - Bind an event in the platform class which listens to the event getting fired in step 3.
The platforms will be notified when any of them are raised, you just need to add the logic to decide what happens once a platform is raised. The platforms will be able to access each other through the Game Mode array.
Note: The GameMode will only exist on the server, so make sure any calculations or calls to the events are handled on authority (server-side).
Thanks so much. I’ll try that out