How to destroy attached weapon?

Use the destroy actor or destroy component node. Or use the set life time node, which will destroy the actor after timer is done (useful if you first use the detach node to remove the weapon actor from the pawn, then set simulate physics to true, and after set life time runs out removes the weapon).

Hi! Need some help with destroying weapon issue. I have a multiplayer game. The other player is AvatarEntity_BP.
He has attached weapon on his mesh.

When he get’s out of the game, the weapon stays in a level.

This is how i’m attach a weapon:

  1. Spawn an actor.

  1. Then attach it.

And this is a weapon blueprint.

I need an advise how to destroy a weapon when a character owns it disappear from level.
Thanks in advance for help!

From where I should call a destroy actor?
I’ve got a parent actor in level:


But when he’s gone, a weapon BP stays in a level:


From inside the blueprint (Player or Actor BP), you have spawned the weapon, OnDeath.

For example

When your actor goes equal or below 0 health, you set a IsAlive? bool variable to true. Then on Event Tick or your function dealing with removal of actors after health goes below/equal 0 health of the actor (or a base class), you add a branch checking for the bool state IsAlive?, once true, you add a detach node (including a IsValid? node to prevent some timing issues with destroy), and afterwards, a delay with 0.2, then add the Destroy Actor node, pointing to the attached weapon actor (Weapon Inst).

Thank you for advise, but is not suitable for my case.
This is because AreaOfView in my game. Suppose it is 99 meters.


Then you move further (101 meter), avatar disappears.


When get back to avatar, you can found an avatar and extra weapon (I moved an avatar to the right slightly)


My avatar didn’t die. It was just removed from the level when distance get over 100 meters, and get back when distance become less then 100 meters. When avatar was recreated, it was recreated with new instance of weapon_bp.
May be weapon_bp should determine that parent actor was destroyed and it needs to destroy himself also? I don’t know how to do that!

You can just hide an actor if he is not in view distance, no need to destroy/recreate him each time. Further take a look at the following examples and download the Shooter Game example from the Learn tab of the launcher.

You could simply make your weapon an Object class(instead of an Actor class). It will be destroyed automatically when it’s not referenced.

Try this, no is the best but work fine :wink:

Put the code in the actorWeaponBP, the event is write in spain lol but sure this can help