Why my enemy is not moving? (not solved, but found a work around)

I have a campaign that spawn an object.

This object have a component listening for its death.

When destroyed, the component creates a new entity in its place. Good, everything works.

But this entity (which is a monster) does not move (not even animate, like a statue).
The strange problem here is that if I spawn it using the debug tools (stamp tool) it moves and even attacks enemies (although it is now part of my team, not the enemy team)

I’m a little clueless, does it needs something more to activate as an enemy when spawned?
I’m using this to spawn him:

   local cocoling = radiant.entities.create_entity('archipelago_biome:monsters:cocoling', {owner = "goblins"})
   radiant.terrain.place_entity_at_exact_location(cocoling, location)

Looking at how the encounters spawns mobs, they all do through the population service and the new_citizen function, requiring a role in the population file. I added the cocoling role to the forest population and used this code to spawn it in.

local pop = stonehearth.population:get_population("forest")
local cocoling = pop:create_new_citizen("cocoling","male")
radiant.terrain.place_entity_at_exact_location(cocoling, location)

Like before, it spawned, but the enemy has no i.a. or animation…

Left side is a perfect monster spawned using debug tools. Right side is the same monster spawned using both the methods above. Notice that it didn’t even show its arms… He don’t move and didn’t even die (his health goes to zero then the icon disappear, but the mob is still there)

1 Like

So, by luck, I spawned the object and because I didn’t wanted it, I destroyed it using the debug tools. Guess what? The monster spawned correctly this way… :rage:

So, when hearthlings harvest it, the monster spawns like a statue (no a.i., can’t be killed, but is recognized as an enemy and hearthlings try to attack).
When I manually destroy it using destroy commands, the monster spawns like it should, going around trying to kill everyone.

Edit:

I’m still not sure why the events are messed up, firing only in this specific situation.
For now, I figured out that I didn’t even need the kill event listener, I simple added my code into the destroy() function of the component for the same effect, and now it runs fine…

2 Likes