I’ve done some multilayer games in Unity before, but I never could wrap my head around who was owning what and finding players through some action they did. Now that I am using Unreal I currently am making a 2d Multiplayer game But I have some questions
1: Each player will need to spawn with a gun actor that rotates and a mouse target box that is invisible but the gun actor looks toward it (I have this working with 1 player at the moment and it also shoots correctly). How would I go about making the gun actor and mouse target set to each player to only have them control it, and not have the other players use it. But I do want the other players to see each players gun rotating though, It is currently a pyramid mesh.
2: How do you know who’s who when creating blueprints for multiplayer? I need a better understanding on this. Say my blueprint spawns objects for the player when he loads the game, and another player also loads through those same blueprints, how do you determine who owns what objects or is it automatically done when they join? I would like to have a better understanding on how someone owns a spawned object.
3: What are ways of identifying players, say player 1 does something and player 7 does something how can I react in code to specifically what player 7 did.
Thanks in advance. Currently question 1 is top priority question 2 and 3 someone could fully explain later, but I want to make some progress with question 1 asap. Thanks
I hope to be able to answer your questions, I am currently learning the ins and outs of networking with Unreal4.
My time is limited at the minute, a train to catch, but once I get back home ill try further answer your questions.
In terms of finding out who owns what, the blueprint function “Switch has Authority” is your best friend. This will branch depending if the object is owned locally, or a simulation of an object owned elsewhere.
Another key element is custom events. If you have used Unity’s networking, you can think of them like RPC calls.
Replication is another key feature that you need to be aware of in order to use.
I am not sure if you are aware of this video series, but it helped to get me started.
How do you let a object be owned by a player? I have a gun that spawns when the player spawns. But before converting to multiplayer because I haven’t yet. How would I find the gun object that should be for the player and assign it to the player. Find actors of class will find all of them but how do I assign it to each player and know which one in the array should be assigned to the correct player?
2: How does this work, should I just add each player when they spawn in to a array and also add the gun object they need to a equal array count, then assign from there? I’m just confused on what determines what is a certain players blueprint code instead of it being random.
Don’t you just add the bullet as a component in the blueprint that is the player object? From there any logic should consider the bullet owned by the player by default. Right?