Skip to main content
edited tags
Link
Philipp
  • 123.2k
  • 28
  • 264
  • 345
Bumped by Community user
Bumped by Community user
Bumped by Community user
added 1324 characters in body
Source Link
Gozmetaiemax
  • 471
  • 1
  • 9
  • 21

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);
}

}

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.

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);
}

}

added 421 characters in body
Source Link
Gozmetaiemax
  • 471
  • 1
  • 9
  • 21

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.

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?

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.

Source Link
Gozmetaiemax
  • 471
  • 1
  • 9
  • 21
Loading