Spawn Emitter on Last Destroyed Actor?

So I have an item spawner and that item spawner is spawning multiple objects at random in three different points.

The issue is that I want to create a particle emitter that spawns on the object I just picked up then destroyed but currently it is spawning on objects that were just spawned at the item spawner which isn’t what I want.

I’m now trying to figure out a way to solve this problem and I am thinking I could somehow check the last object I held or if it was destroyed and spawn emitter however I am very confused about how to go about doing that.

Can someone help me out a little bit with understanding how to do this better?

Does this objects all share a same parent class that you can edit? If not, I think its a good idea to reparent each one of them to a class that you can edit (Inside blueprint editor->File->Reparent Blueprint).

So you should some hierarchy like: Actor->MyCustomParent->[EachOtherObject]

For example, lets say you have a briefcase, a knife, and a pistol.
Instead of having:

You should aim for:

So any changes and functions you create on the “Items” class would propagate to all objects.

When you have all of them sharing the same parent class, inside “Items” class you could create a “PlayPickupEffect” function or event that you can call whenever an item is picked up by the player. This function would be avaible for all items (Briefcase, Knife and Pistol). Inside this function or event you do whatever you need to do: spawn emitter, play sound, send a message, etc etc. Its up to you.

Best of luck in your project,


Thanks for the suggestion. Hmm, I don’t quite understand how changing the class is going to help with that though but I will look into that. I usually just set a reference so that I can grab the master bp of the items but I think I get the idea and will take another look at this later on today when I can.

It helps because you do a “Cast To Items” and it will work for all items, instead of having to do Cast To Knife, if failed Cast to Briefcase, if failed Cast to Pistol.

All functions functions and variables that are shared across all items you should store inside Items class, so that you can do these kinds of ‘generic’ castings that will work for all items you have.

Lets suppose your items have durability, and anytime they get shot the durability should decrease.

So inside your bullet’s code/blueprint, you can do something like this:
ComponentOverlap->CastToItems->Durability -= 1 (decreases items durability by 1 when shot with a bullet)

And this code in your bullet would work for knives, briefcases and pistols.

If you have a PlayPickupEffect defined within you Items class, you can do a CastToItems->PlayPickupEffect in your character or anywhere else, instead of having to first discover which item class it is and then call its own pickup function that can even have different names and be completely different (not really the same function is going to be called if they don’t share the same class)

Okay cool, I think I get it now, thanks so much for the additional clarification and assistance.

I figured it out, thanks, just trying to figure out how to get it to ignore my Pawn…