Jump to content
SovietKitKat

Spawning a Prefab with child entities

Recommended Posts

Hello! I've been struggling with getting spawning prefabs with child entities working in my mod. Even with a Hierarchy component, it only appears to spawn the root entity. Using IEntity's GetChildren method on the instanced prefab doesn't return the first child as I would expect.

 

The method I'm currently using to spawn the prefab is to load the resource using Resource.Load, and then to instantiate the prefab with g_Game.SpawnEntityPrefab

 

It doesn't need to use Replication, as the mod is single-player only.

 

Has anyone else struggled with this and come up with a solution? Not being able to access prefab children is a major blocker for progressing on my mod.

 

Here's some screenshots showing my current setup.

 

EAkSTwAm_o.png

 

GUEq1ABt_o.png

 

9iQeg1u5_o.png

 

Share this post


Link to post
Share on other sites

That's interesting. I use the same spawning technique for instantiating slot compositions (LivingArea, Bunker, Checkpoints etc). 

 

From what I can see, lets take LivingArea_S_US_01_1 
They have a hierarchy component on every single object in the prefab. From parent to children. Your screenshot looks like you only had the hierarchy component only on the parent? Which to be fair makes more sense to me than having it on every child entity in the prefab.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×