Spawn enemy character inside an actor blueprint

I am working on a 2D Sidescroller game. I have created an actor blueprint where I have added tile maps and other components. I have created more such blueprints to increase the level. I don’t know whether this is right approach or not for creating items.

In the actor blueprint, I can successfully add coins using " Add Child Actor Component" but when I use the same function for adding an enemy that follows player when he comes in range, the enemy is added but it doesn’t move.

My enemy is a Character class and when I directly add it in the viewport in level, it works perfectly and follows player

Is there any way by which I can spawn/add my enemy from an actor blueprint?

open your character and in the details panel find where it assigns the ai controller (i think its in the pawn section maybe, i dont have the engine open right now). theres a option there for ai posses thats probably set to placed in level, change that to placed or spawned.

Edit: i just opened the engine and the option you need to change is auto posses ai which is in the pawn section.


I have tried changing this setting but my enemy still can’t move.

I amusing a blueprint class for adding each tile map and other actors inside that tile map. I have noticed that in those blueprints where I am not using Construction Script, I can use Spawn AI From Class function to spawn my enemy and it is working right and following my player.

But in those blueprints where I have used a Construction Script, I am unable to use Spawn AI From Class and only option that is available is Add Child Actor Component which is only adding the enemy but the enemy doesn’t move.

Thanks for the solution. I have shifted all the spawning work from Construction Script to Event Begin Play and everything works fine. From last 2 days I was stuck with this problem and now I can proceed into building my levels. Thanks :slight_smile:

Contruct happens before the actor is finished spawning into the world.
Actors fire BeginPlay after they are done constructing, so it makes sense to put anything that requires them to exist in the game world in the BeginPlay event rather than the constructor.

Youre welcome. I have converted my comment to an answer so you can mark it Accepted to help others with the same problem.