Having issues with character spawning....

Currently having an issue thats been a headache in UE4 for a long, long time.

I’m currently making a 2D side scroller co op game. Similar to all of the old arcade game. What id like to do is spawn a character for each player. However, I want this character to be different based on the player number.

I spent weeks trying to get it to work in C++. I tried spawning pawns manually and possessing, and it wouldnt work correctly at all, with little help from the community. So went down the route of overwriting what class gets returned as the default when spawning. Could only get it to change colors with a random number generator. Any attempts at accessing player id would crash the editor. So got left with random. And it kinda worked. If you had 2 players, it was great, but any more and at least one would never get possessed. No matter how many times I rewrote the code. Lets not forget that sometimes it would random spawn extra pawns on its own, even when I wouldnt touch any spawn code other than the class variable.

So I gave up on C++. Figured, hell, fine, Ill try blueprints. So tried that route. Here are my attempts and where they failed.

  1. Getting an array of all player controllers, having a for each loop to iterate through, and spawn the color based on the current index in the loop. Apparently the switch broke and the array was never filled, as they all defaulted. However that same reference at that same index in the PlayerController was used in possession and it worked. Kinda. Each player possessed a different pawn, but they were all blue, (the pawn the switch defaulted to) and they couldnt move. Could duck and change direction, but no movement whatsoever. (Pawns are definitely set to replicate This happens regardless of if running multiple players or not.

  2. Placing one of each character manually, and on begin play getting a reference to a player controller based on index, and using possess to possess the pawn. Didnt work at all.

So, I’m about ready to trash this project. The whole premise was based around the co-op and each player is needed, as each player presents a unique ability to help succeed.

I guess before I move forward with something new, I’d like to ask for ANYONES feedback in what I can do. The C++ side was pretty terrible with giving support, so I guess Id try these waters.

Again, Heres all I would like to do.

4 players. Each one gets its own color. Player 1 gets blue, player 2 gets beige, player 3 gets green, player 4 gets pink.

At level start they all spawn, or get possessed and play starts. That is all. Any help is greatly appreciated.

I apologize if I sound bitter, but I’ve been banging my head against I problem I figured should be really simple in this engine. I guess I was wrong…