So I’m trying to make it so when the player collides with the enemy it first plays the effect then destroys the enemy actor and restarts the level eventually I wanna have it also take away from a life counter I had the basics working until recently I don’t know what happened it just stopped working it will play the effect then destroy itself but wont restart the level.
I don’t know how if desotrying actors is instant or if it waits for the garbage collector to do work.
But looking at the code I have an idea, you call “Destroy Actor” on the actor itself, and then the timer you created (2 second delay), which is attached to the actor, is also destroyed. Therefore, nothing happens after the 2 seconds. (Just a theory)
yeah taking away the timer works but it doesn’t play the effect afterword’s it just immediately starts the level
If you about to open a level in 2 seconds, why not make the actor not visible instead of destroying it. It being destroyed is why its not calling the open level. There are a large number of ways to do what you wanna do, but if you want a simple fix there you go.
yeah I tried that it only wants to work when tthe player character hits it but it will just keep colliding otherwise and when I replaced hit with begin overlap it worked more smoothly but it collided with everything
Hey there @Donaldk31888! So there’s a number of ways you could handle it really. You could disable visibility and collisions as Oortiz suggested. If you want to disable collisions on your actor:
However for all game actions such as loading new levels, I’d recommend having those transitions in either your level BP or your Gamemode and calling them when all of your enemies are destroyed, then you don’t have to worry about any actor containing the logic being destroyed and being unable to transition.
Hope this helps!
yeah its solving all but one of my issues the enemy only activates when the player actively collides with it other wise it just bumps into the player
What do you mean just bumps into the player? Like the Hit event is not firing?
exactly
Before you set the actor to no collisions? If it only hits when the player is walking into them, I’m guessing the enemy’s movement has sweep enabled. This checks to see if it’s coming in contact with anything if it moves and doesn’t move it. Either that or the enemy is stopping short of the player. May I see the issue in action?