Download

Need Help Creating separate health variables for both my characters.

I am pretty new to Unreal but have been making steady progress. I have started designing a small personal game project. The game uses networking features, which I am mostly familiar with and I have also seen the tutorials which aren’t helping here. My problem is that I am creating the basic health variables while setting up my HUD, however I am pretty sure that if my “Fighter” blueprint that my default pawn is set to, both of the player starts will spawn separate pawns that have exactly the same health value all the time. My first thought was to have two separate blueprints for each character that have essentially the same code, but different health variables (Health1 and Health2 e.g.) however having these two separate characters would mean that the playerstart could not spawn two different actors depending on the start. What would be the best way to allow my separate players to have separate health values while still using player starts. I have looked around and have gathered a good way to do this would be to destroy and replace the network actor with a my second character but surely the nodes for this would have to be in that ServerCharacter blueprint instead of the ClientCharacter one and so I couldn’t do that without destroying them both. I’m completely lost and need help.

Instead of using player starts, you can just manually place each character in the level at the location you want them to spawn at.

Use inheritance in this case. Create a Base_Fighter class and then inherits from and change whatever value you wish. Do not need to duplicate code in this case.

PlayerStart is just a point in space which will be used as a transform reference for upcoming controllers to enter the session and spawn their characters. There are many other objects/classes you can explore to achieve your result, I highly suggest you learn from this book

If I’m not mistaken, you can change the player’s default pawn by overriding Event Post Login (inside GameMode class), that is called before spawning the default characters, and setting the controllers default pawn.