So I have a very simple flow so far in a prototype. Currently I have a health system that destroys the enemy actor when health hits 0. Well I want to spawn a coin on death. Well actually I want to spawn a random number of coins.
I have all the blueprints made but when I try to spawn the coin at the point I destroy the enemy actor it crashes the engine.
Any thoughts would be great!
Try this and see how it goes:
Spawn Emitter > Detach from Parent > Play Sound > Destroy Actor.
The branch is the one you have, connect the “spawn actor” to your print string and skip your spawn emmiter.
This crashes the engine every time. I think it is because I am trying to spawn something after the parent actor has already been destroyed?
This particular spawn if for a spawn actor class. The emitter in the current blueprint is for the explosions particles. When I spawn actor class it crashes.
Where are you spawning the actor exactly then? I assumed it was the particle but in any case, try detaching the spawned actor before destroying the BP.
Have a look at this. (This is what I did that caused the engine crash).
Are you referencing this actor via Cast or interface anywhere else? If not does it still crash if you destroy the actor without spawning another actor? Does it crash if you destroy the actor elsewhere?
The enemy is a blueprint. I am currently just dropping him on the map. He is being destroyed by a projectile, that is cast in.
I am attaching images of the entire BP.
I am able to spawn in the treasure with key press and in other forms.
It looks like you have it setup to get the transform of the projectile and spawn coins there. I’d imagine that the projectile is destroyed on contact with the enemy. If so, you’re trying to get the transform of an actor that doesn’t exist, this might be this problem. An easy fix would be to spawn at “self” rather that the projectile.