Search Unity

  1. Unity 2020.2 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Entity Particle System

Discussion in 'Data Oriented Technology Stack' started by shotoutgames, Jan 16, 2020.

  1. shotoutgames

    shotoutgames

    Joined:
    Dec 29, 2013
    Posts:
    226
    What method if any to add a Particle System Game Object to an Entity Bullet.
    Previously when using Game Objects I would just make the Particle System a child of the moving bullet to add a particle effect.
    I have been experimenting but without success.
    Thanks
     
  2. TRS6123

    TRS6123

    Joined:
    May 16, 2015
    Posts:
    165
    Code (CSharp):
    1. entityManager.AddComponentObject(entity, particleSystem);
    2. entityManager.AddComponentData(entity, new CopyTransformToGameObject { });
     
  3. shotoutgames

    shotoutgames

    Joined:
    Dec 29, 2013
    Posts:
    226
    I am pretty newbie so not sure how to implement this.
    I was using IConvertGameObjectToEntity and it wont add the particle system to my prefab bullet entity.
    I can add it to a bullet in the scene but I need the particle to be in sync with the entity positions for all instances as they travel.
     
  4. Opeth001

    Opeth001

    Joined:
    Jan 28, 2017
    Posts:
    748
    the way i see it:

    1) spawning Projectiles Entities with EffectID CD.

    2) a LinkPrefabsSystem (ComponentSystem) tracks all entities with EffectID but without EffectIDSystemState and get the required Prefab from pool otherwise instantiate a new one.

    the correct way to link a transform to an Entity, (make sure your entity has the LocalToWorld cd)
    Code (CSharp):
    1.  
    2. GameObject BulletPrefab; // a normal gameObject from Pool
    3. entityManager.AddComponentObject(ProjectileEntity, BulletPrefab.transform);
    4. entityManager.AddComponentData(ProjectileEntity, new CopyTransformToGameObject { });
    5.  
    3) the ProjectileEntity do it's job and get destroyed.

    4) a RecyclePrefabsSystem (ComponentSystem) tracks all entities with EffectIDSystemState but without EffectID,
    * recycle the prefab used,
    * removes the EffectIDSystemState
    * destroyes the ProjectileEntity .
     
unityunity