I am getting this error:
but the entity I am trying to instantiate is an entity that was created from a GameObject
prefab using the ConvertToEntity
script; so it should have Translation
by default right?
I think I am getting this error because of the way I am getting the entity data.
Here is my setup:
-
I created a
GameObject
prefab (I’ll call it meteoroid), which contains theConvertToEntity
script, and a proxy mono behavior for theISharedComponentData
Destructible
. -
The Destructible proxy contains reference to two
GameObject
prefabs, one calledHitEffect
, and the other calledDestroyEffect
; both have theConvertToEntity
script. These are converted to entities using theGameObjectConversionSystem
in theConvert
method and stored in theISharedComponentData
. -
A “Spawner” proxy mono behavior contains a reference to the meteoroid prefab and converts it to an entity and stores in the Spawner
IComponentData
. -
A Spawner
ComponentSystem
instantiates copies of the meteoroid entity everywhere randomly. -
If a bullet raycast hits a meteoroid, it adds a
IComponentData
HitData
, which stores the entity it hit and hit position etc… -
Finally, a Hit
ComponentSystem
looks for any entity withHitData
, grabs the entity from it and gets itsDestructible
property. It looks through it, and instantiates either theHitEffect
orDestroyEffect
; this is where I am getting the error.
AddComponent
does not work for me in this situation as all the other data from the prefab is also gone (including the rendering components). So I want to ask, is it possible to convert and instantiate prefabs that are stored in other converted prefabs? Or what am I doing wrong?
Here is code: gist