Hi,
Bellow you can find my 2 scripts, I am also am using a convert to entity, with convert and inject game object. The attached image is the game object I am controlling with a separate script and the 2nd game object that doesn’t move but shows up in the entity debugger.
I don’t know why this 2nd game object is created.
My Player to Entity Converter is:
public class PlayerToEntityConversion : MonoBehaviour, IConvertGameObjectToEntity
{
public float healthValue = 1f;
public void Convert(Entity entity, EntityManager manager, GameObjectConversionSystem conversionSystem)
{
manager.AddComponent(entity, typeof(PlayerTag));
Health health = new Health { Value = healthValue };
manager.AddComponentData(entity, health);
}
}
My Player Tag component:
[Serializable]
[GenerateAuthoringComponent]
public struct PlayerTag :IComponentData
{
}
That’s what Convert and Inject usually does. Is there a reason you can’t use Convert and Destroy?
If you are using inject with something that has a renderer, for now it results in the awkward situation where an entity is created with the converted RenderMesh and your original MeshRenderer still hangs around. You could simple disable it somewhere in your code. Another option would be to create a custom ConversionSystem to remove the RenderMesh after its been added(tbh I cant remember what the result is if you attempt to remove a component that is automatically converted inside the Convert interface but this might be something to try too).
note - its not a second gameobject(unless theres more to this that has not been mentioned), its your original gameobject that you setup in the scene.
It all depends on what you want from your end result.
Thank you!
I am trying to get, a setup similar to Unity’s AngryDOTS project. As I will be using a rig that I can only use with MonoBehaviors and cannot convert directly to an entity. I didn’t know injection will do this. I am now doing rendering on a child without conversion and it works fine.