how do I Spawn Actor on AI death?

Hey all
I’m probably too tired to be trying this tonight… but…
I’m just trying to spawn an in-game item at location of the AI corpse.
For testing I did a “spawn actor”, chose the class as my blueprint “Shortsword”, did a “get actor transform”, and then that’s where I am stuck…
I can make it spawn directly on my player by doing a “Get player character” but everything I try does not spawn it on the AI pawn…

Little help for my weary brain?
Also, what would I do to go about making it a % chance drop? so that it may not always drop when an enemy dies?

Thanks

Do you destroy actor when they die…I’d think this has something to do with it being “dead” and your player character still being around…I’d need more info or a screenshot but I’d suggest looking into when you’re spawning this “shortsword” and see if moving it a little earlier down the execution chain helps…

Hmmm maaaybe…
I took away the “Get Player Character” node and now this is where I am stuck


What do I have to add to that to have the shortsword spawn where the body was? Some kind of world position… or reference to the AI character…?

Try and spawn the actor before you set physics and destroy their capsule component…really just move the spawn Shortsword up in the chain and check that “Spawn even if Colliding box”…all of this stuff is happening faster than humans can determine so won’t make much of a difference to us where that spawn shortsword is but will make a difference in blueprints… also likely best to drag off of you mesh and say get transform and plug that component transform into your Spawn Shortsword transform…not super important but may make a difference with some enemy types…

Ok, I’ll try that when I get home from work in an hour or 2 and edit this reply with an Update. Side note…
With it as it is… The shortsword spawns but like… 15 feet away from where the enemy dies lol… Always the same spot when I re-play the map…
Going to create a new flat map for testing purposes :slight_smile:
Thanks President.

EDIT
So seems that did it! It completely drops instantly at the place the enemy dies. Sweet :slight_smile:
I’m not sure if I completely understand it… but I’ll go with it!
02e47250a4e3a25cbd798289c61f6078d8da6697.jpeg

Thanks for the help President!
Any ideas on how I could make this spawn by a percent chance on death?
Eventually I think I will probably need to have an array set up that will have multiple items that can drop.
That could include base Craft items, maybe an armor or a weapon or just trash that can be sold to a shop to make your character some money.
But for this single item, what would be a method of causing a percentage chance?
EDIT 2

I think I found out myself :slight_smile:
Using this PAGE


I created a new Blueprint Functions Library as described on the answerhub but named it Chance
I then called Chance and created the branch, If true and the Integer hits on the 30% Spawn Actor and destroy enemy, if NOT true just destroy the enemy.
This way in any enemy I decide to put in the world I can call a Chance function and give individual Monsters their own Chance to drop something!
Feels good to get something working!

Old post I know, but I was just looking for this solution (thanks for posting!!) and I also wanted to pass along a way to make this more efficient without having to copy and paste blueprint script. Since the method you use to destroy the character is identical whether or not you spawn the item, on the branch node, you could take the FALSE output and connect it directly to the input on the Set Simulate Physics node that’s already attached to SpawnActor item Shortsword. This way you’re using the same code for destroying the character, rather than having to copy and paste it :slight_smile: