Spawn object and replication

Hello everybody!

I am doing a spawning tool in my game. I would like that, when a player press a button in a UI, an object spawn. Actually, I managed to do it :

In my interface when the button is clicked I launch a RPC event on the player state. Then, I call a multicast event and spawn object in this event. It works well but I am not satisfied. At the beginning I tried to do the following :

  • Call a RPC event that is in Player state, from my UI

  • in the RPC event in player state do the spawning.

This was not working, but I have no idea of why.

Question 1 : Does someone could explain me why ?

Now, I would like to destroy this actor when a player press a key. But if I destroy the actor it does not destroy on client (since each client has they own actor replicated).

I tried to do the following :

  • From the BP of the spawned actor, call a RPC event that is in my Player state

  • in this RPC event call a multicast event that will destroy the actor.

This is not working : If player 1 come and take the actor, it is not destroy, even for him. It is only destroy for the server.

Question 2 : I would like to know if someone can explain me why it is not destroy for other players.

Sorry for my mistakes, I don’t speak english very well…

Thank you for your answers !

All the best

Hello, I have partially solved my problem. I didn’t realized that since we can’t simulate physics properly in multilpayer (just by checking the option), it was the reason why when I spawned the object in a RPC event it doesn’t work.
I found a new solution that work well without having to do a multicast to spawn the object and see the object falling on the floor as I would like to do :
Instead of simulate physic you can, to make an object fall on the floor, use it as a projectile. It is quite strange I think but it works well. You will not be able to shoot the object and make it move next but it will fall. If it is just what you want it is ok.

So, I had partially solved my problem, since I am still not able to destroy the object for everybody easily.

Ok I solved all my questions.
If you have spawn the object using a RPC event, you will have to destroy it exactly in the same way you create it :

  • Call a RPC event and give in input the actor you would like to destroy (This event must be somewhere like in the Player State)

  • In this RPC destroy the actor that you have in input.

If you need help to use projectile, this video may help you : WTF Is? Projectile Movement Actor Component in Unreal Engine 4 ( UE4 ) - YouTube

I hope it will help someone in the futur ! If someone have a better way to do it please don’t hesitate.