Problem with Actor replication and Health Bars

I am trying to make simple multiplayer prototype.
This is my Play screen with 1 server and 2 clients!

Problem 1:
I have 3 Spawn Points, only 2 actors spawned! 1 Client, and 1 Server, second client didnt, even tho there are no collisions that are blocking spawn points or anything.

Problem 2:
When i click Left click to fire, two instances of spawning actor are spawned on clients, but on the server side, there is only 1 instance as it i shown in the picture here.
Implementation:

And the health bars:

As you can see both Server and the client for some reason share the same health bar % even tho their healths are diffrent…(100 and 30), i dont know what could be causing this problem…
If further implementations of blueprint functions are needed i would send picture ASAP.

BUMB

Still waiting for answers… I could not find the soulution…

Hi, for your bullets:

If you set them to replicate, then spawn them on the server only, not on the clients. Because they are replicated once the server spawns them they will also exist on all the clients.

Your problem is that you set them to replicate and spawn them on server and clients, therefore the server will only see the bullet he has spawned, but the client will see the bullet the server has spawned and the bullet he has spawned.


For your health bar:

Can you show the code, where you set the health bar percentage?


As for why there is only one client spawned: no idea.

But you can try to spawn them manually and debug from there, so set the default pawn class to none, and then in your player controller on event begin play, you can spawn and possess your pawn on the server.

Bullets:
@chrudimer is right: if the bullets are replicated, you need to spawn them only on the server. That being said, if the bullets only travel in straight lines, an alternative solution would be to just stick with your current code, but turn Bullet replication off. This way, your bullets incur no network cost after they are spawned. I believe this is how older Unreal Tournament games handled certain guns like the flak-cannon: it was too costly to replicate every flak piece, so you just send a network event whenever the cannon fires.

But you need to pick one strategy or the other, right now it looks like your code is trying to do both

I would really suggest doing this video tutorial series from start to finish. It only took an afternoon, but it helped me a ton:

It covers everything: Player Spawning, shooting projectiles, and even replicating player health bars (it’s probably best to use the “RepNotify” strategy for that).

Thanks for posting, but i actualy did watch this series. And i tought i understood it well. But seems there was something i was missing…
Also thanks for commenting, and thanks to chrudimer, because it did help me solve problem with bullets!
As you said, i tried both strategies…

Thanks for clarifying problem with actor replication. It helped me!
Here is health bar code:

In component list, Widget is set to Component Replicataes = true.

Hmmm, interesting that it works for the client but not for the server.

Can you “print” the “Owner” in the “Get Percent 0” function before the “IsValid” node? And can you also print the “GetOwningPlayerPawn” after the “EventPreConstruct” node? So to make sure that this is set correctly.

And widgets never replicate, they only exist on their owning client.

Here: I made slight adjustments

As you can see, there is still problem with one client not being spawned… I can do it manualy, but i didnt… I just set that Number of players = 3. Not running dedicated server.

here is case when both cleints spawn…
I can see they are both possessing myPlayerPawn1 , but i think thats fine, becose its local for the machine thats running the code?

but i think thats fine, becose its
local for the machine thats running
the code?

No they should have different ones, so you should have “myPlayerPawn”, “myPlayerPawn1”, “myPlayerPawn2”. From what you have printed client 1 and client 2 will display the same health percentages since their widgets are referencing the same actor.

Where are you setting the owner/ where do you create the widget?


By the way, I wouldn’t use Preview Versions of the engine for active development, since those are not guaranteed to be stable and you might bring in new bugs when converting your project from the Preview Version to a stable release. So they are only meant to be used for testing purposes for you trying the new features/looking for bugs.