Destroy actor on server-side / interact between BPs without casting

Good morning everyone,

im trying to figure out how to destroy an actor when I “collect” it in a multiplayer game. I know the actor needs to be destroyed on the server-side, but since Im new to scripting, Im struggling to understand how to do it.

So far, I created a custom event on the server, which calls a multicast event on the client, and from there, I call “Destroy Actor”. I did all of this inside the ThirdPersonCharacter, which I assume is server-sided?

Now, my main issue: How can I call this custom event from inside the actor (without casting for performance reasons) and communicate with the ThirdPersonCharacter to pass the “target” of the “Destroy Actor” function?

Thank you on advance:)

Hey,

So with Networking if your Actor that you want to collect and destroy is marked as Replicated then just calling Destroy on the Server should replicate that down to all Clients automatically so you shouldn’t need to do anything from the client side there.

Heres the Unreal network compendium a great guide on working with networking - Multiplayer Network Compendium | An Unreal Engine Blog by Cedric Neukirchen

Thanks for the link i will try to learn from it.

What I meant is, how do I destroy the actor on the server?
If I call the event inside the ThirdPersonCharacter, I still need a reference for 'Destroy Actor" (“Target”) from the other blueprint that I want to destroy. How can I get this reference without casting?

So the method I would go with here is detecting on the Collectable Actor when an Overlap has happened and check if this is the Authority (HasAuthority node) and if so check if the Player was the Overlapping Actor (You can cast or check Actor Tags or however you want to do that check).

From there you can just call Destroy as you know you are on the Server based on the HasAuthority node and you know it overlapped with the Player. If you need to do something on the Player you can always cast to the Player or grab a Component on the Character and run logic through that before calling Destroy on itself.

Do you mean it like this? The issue here is that if I overlap with the client now, the actor will not be destroyed.

Is the Actor replicated?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.