Spawning of Actors in Multiplayer
Hi there, so im creating a multiplayer RTS and i need the players to be able to spawn in a set of user defined ships. The information is currently entered by the user in a widget and passes the ship information via a structure to the game instance where, when called, the event should create the ships and apply the information to them. The event on the game instance is replicated to server and the ship class is set to replicate.
Currently however, when the host calls the event, the ships spawn on both players screens and work just fine but this isnt true for the client. If the host calls the event first, when the client calls the event nothing happens at all. When the client calls the event first, the clients ships spawn only on the clients screen and the host spawns on both.
Ive tried pretty much all combinations of replication on both the event and the actor but i cant seem to get it to work. Attached : Screen of the latter part of the custom ship building UI and event call and a screen of the game instance BP portion that should handle the spawning of ships.
Im unsure as to what to do here, any assistance is very much welcome.
Further info available if needed.
Thanks in advance.
Solved it: Here's what you need to do: Make a special event that only runs on the server side for each thing you need to be replicated. Then, when it's time for the player to do it, call the event that runs on the server. From there, it will replicate to the other players (replication works from the server to the clients, not the other way around). If you want, I can show you how I have my blueprints. FOR EXAMPLE: you need your character to spawn a box when you click. Your character calculates the transform of the box, then call the event that happens on the server side (costum event within your character blueprint with the "replicates" option in the details window set to "run on server")
Try with new live training made by unreal engine 4 staff https://www.youtube.com/watch?v=hlDWovBcu7E&t=967s
answered Apr 09 '17 at 02:31 PM
Im close to giving up at this point. All i need is a damned tickbox generated as a bool in a widget on the client to be visible to the server. Ive tried saving to player controller and using a gamemode based list of connected players to access it, nothing. Ive tried saving to the in world character and using a get all of class, nothing. Ive tried to setup a player state and saving the bool in the player state but now a bunch of other stuff has broken.
Im at a loss and i cant find any one capable of assisting me. So far the closest ive gotten is a vague, non-answer from MK Studio...
Ive been using switches on authority, replicated events and variables and the closest i can get is a local client-only result where the server is unaware of the change done locally and thus cannot act upon the change. Ive been working on this for about 5 weeks, been following tutorials, asking for advice and i get nothing.
Follow this question
Once you sign in you will be able to subscribe for any updates here