Actor does not replicate properly

Hi,
I am working on an online game made with blueprints and i have come across a problem while trying to spawn projectiles from my gun.
The single player version works just fine, i spawn the projectile and i adjust some variables in the projectile (such as color, speed, trajectory and stuff like that).
For the multiplayer version i tried to create a custom event replicated on server which takes all the values i need and spawns the projectile (which is replicated of course).
So as soon as the client (or server) presses the mouse button the run on server function is called but the projectile spawned it’s visible just on the server window.

The graph above shows what is called as soon as the mouse button is pressed, the spawn on server function is succesfully called on server and it works.

The graph above shows the spawn on server function definition where i basically spawn the projectile on the server.

109762-untitled2.png

The image above shows the replication options on the Projectile actor that i spawn in the spawn on server function. As you can see everything is properly setted.
So the problem here is that with this configuration when two players are connected (one client and one server) the server is going to see his projectiles and the client projectiles while the client wont even see his own projectiles.

Try setting the floats to replicated. I think the server command is just retreiving 0 if the value isn’t replicated.

The variables are client side and i pass them into a function, and that function uses the parameters. Anyways just to be sure i set all the floats to replicate as you suggested but nothing changed. When i shoot with the client the server can see the bullets the client spawns but on the client window i can see nothing.

Ok sorry not home to look at my blue print that leave on the initial event make the server event run a multicast of the function so all clients run it.

Ie: button → server → multicast → spawn projectile

Though I’d make sure the orojectile is actually set to replicate first

Yes it should be replicating, the screenshot above shows the projectile replication options.

Part v and vi goes over spawning a bomb over multiplayer

Should be the same.

If it’s not working doing what’s done in these videos might help narrow it down.

Thanks! i will give it a look

Alright i watched both v and vi and he does more or less the same things i do (except for the variables i am passing in the function) i checked everything he did and i did the same… still mine isn’t working

I’d put a print on a is valid check for true and false on the return of the spawn actor. See if you get a false. Whatever your settings on the projectile you might want to consider expose on spawn so you can link directly into the spawn actor from class. It may be assigning the values before its spawned on client.

it always prints “IT’S VALID” both when i shoot with client and server, so no problem with that… i will try to expose all the variables now.

Alright, while exposing the variables i actually realized that none of the bullet variables was replicated, so on the client those variables weren’t set and the bullet wouldn’t even render because one of the variables is the material. Thanks for helping me spotting the problem

Hey Marvash,

This is how I normally handle Projectiles:

“Scene” is a temp Scene Component in the Character. Normally this would be a socket location or something to fire from as a “muzzle”.

alright i figured out what was wrong… i set the projectile actor to replicate. The projectile actor has 3 components: projectile movement, sphere collider and a static mesh component. Apparently even if the projectile actor is set to replicate it’s not sure that all the components will replicate. To solve this i just created an event called as soon as the projectile is spawned in which i tell all the components to replicate with the set is replicated function. I can now see the projectiles from both server and client and everything is good, thanks to everyone.