How to assign a player to a player object in multiplayer

Hey! really new to multiplayer but rn I have a game meant for 2 players and I want each player to have their own distinct character. Right now I have both objects set as a player object but what happens in the game is that one player gets to control both characters and when the second player connects, the game will make a copy of those two player objects for the second player to control. Is there a way I can assign the first person to one object and second person to the second object?

Any time someone joins a multiplayer game, they get their own controllable copies of “Player” objects. If you only want there to be one Player object per person, only put one of them in your level.

If you want them to look different for each person, you can use an Animation or Attacher to modify the sprite.

@grazer is it possible to control where the copy spawns? Right now the second player will join and spawn right next to the first player.

Player objects spawn where they are placed in the level, like all objects. If they have collisions and are in the same spot, they will shift so that they are right next to each other.

If you want to spawn them in a specific location, you can spawn them with a spawn behavior block, just keep in mind that only Player objects can spawn Player objects. The game “Apocalypse Arena” works this way: there are spawner portal objects (they are type Player, so everybody gets one) and they spawn the controllable Player object in specific places in the map.

2 Likes

I have a question that is a little different, @grazer. Since you all get the same coppies, how is it possible to make them do different things? I tryed the player count behaviors, the first one in is player one and the second one is player two, but that isn’t working. Also, I need to message an object to keep the score, but since they are the same, it doesn’t work.

The player objects are controlled by each local player, that’s how they can do different things, even though the logic is indentical. Maybe I misunderstand you though?

Also, player count block is intended to show the number of connected players, I’m not sure what sort of issue you’re having with them.

Keeping score is pretty tricky in a multiplayer game as well. Basically everything is harder and more mind-bendy when working in multiplayer, for exactly the reasons you describe.

1 Like

Can you give a description of player count? That might fix it.

Or, @kevinyang, could you post a link to the game you’re making? I might see how you did it and get an idea. I just got indie yesterday so it is new to me.

That was in January- I doubt they’re still on the project…

I know! Then they’d be finnished, right?

I don’t think they’re on the forums anymore, I’m here everyday and they haven’t posted in a LONG time.

Oh. I see. Do you know anyone that has made a multiplayer and is still here? (except grazer XD)

What would you like to know?

1 Like

How you can keep score. For example, how would you add a scoring system for all the players in dirt.io?

2 Likes

Do the same thing as a multiplayer hp bar by attaching a block to a player that changes nunber when score goes up.

1 Like

Hey @Flying_Fahita! DinoDev is right, I’ve been inactive for quite a while. The multiplayer issue I had was still there but I did find a way to go around that. I don’t remember how, but I’ll go ahead and leave the link for that project here so you can take a look if you want

2 Likes

Quite impressive, love the game remake!

1 Like