1
\$\begingroup\$

Was working on ECS and following the tutorials by Mike Geig in Unite Copenhagen on YouTube(https://youtu.be/BNMrevfB6Q0), and understood that unity automatically converts transforms, mesh renderers and things like that to ECS, the IConvertGameObjectToEntity interface converts entities that I want specifically for my game. But, while following his tutorial exactly as he did it, the entities that I have on my game do not have colliders in them, but is seen in his demo, how do I resolve that?

EDIT: I've Instantiated an entity, and it works fine, but then implementing the void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem); from the IConvertGameObjectToEntity interface, I just have an entity, and only the mesh is visible, and an empty Component data that I've assigned on the Convert() method is available, I don't have a collider as it is on the prefab.

Here is my Spawn Entity Code:

void Start (){
        manager = World.Active.EntityManager;
        ObjectEntityPrefab = GameObjectConversionUtility.ConvertGameObjectHierarchy(ObjectPrefab, World.Active);

        for (int i = 0; i < 100; i++)
            SpawnTheObject();

}

private void SpawnTheObject()
{
    Entity object = manager.Instantiate(ObjectEntityPrefab);

    manager.SetComponentData(object, new Translation { Value = transform.position });
    manager.SetComponentData(object, new Rotation { Value = Quaternion.identity });

}

Here is The code attached to The Object:

public class AsteroidLifeECS : MonoBehaviour, IConvertGameObjectToEntity {
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
{
    MoveSpeed moveSpeed = new MoveSpeed { Value = MovementSpeed }; //A component data that has only one float called Value
    dstManager.AddComponentData(entity, moveSpeed);

    RotateSpeed rotateSpeed = new RotateSpeed { Value = RotationSpeed }; //A component data that has only one float called Value
    dstManager.AddComponentData(entity, rotateSpeed);

    Health health = new Health { Value = Health }; //A component data that has only one float called Value
    dstManager.AddComponentData(entity, health);
}

}

\$\endgroup\$
1
  • \$\begingroup\$ Can you walk us through the specific steps you took? You'll tend to get better answers, faster, if users can follow your repro steps as text rather than taking time (and data) to watch a whole video tutorial. \$\endgroup\$
    – DMGregory
    Commented Nov 2, 2019 at 3:32

1 Answer 1

1
\$\begingroup\$

There is capsule collider attached to the bullet in the tutorial, But Mike Geig did not explain any thing about physics and collider, But as much i know unity "MonoBehavior" physics is not working with DOTS Entities.

So you have to install either "Havok Physics" or "Unity Physics".

enter image description here

More about Physics you can watch tutorials:

  1. Leveraging DOTS-powered physics - Unity at GDC 2019.
  2. NEW PHYSICS IN UNITY 2019! Beginner Friendly Overview.
  3. Overview of physics in DOTS - Unite Copenhagen.

Note: I have not tested any of the package. So i could not tell how to get started with it, But there will be information in videos links I've shared.

I hope this will help, Sorry As I am not experienced with any of the package so I am not as much help full as I wanted to, Sorry.

Good Luck.

\$\endgroup\$
1
  • \$\begingroup\$ Sorry for taking a lot of time to reply, but, the Unity Physics package did not solve the problem. But I'll check out the other physics DOTS tutorials. Thanks anyways. \$\endgroup\$ Commented Nov 3, 2019 at 15:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .