E
E
Eugene2019-08-08 14:47:10
Game development
Eugene, 2019-08-08 14:47:10

Unity ECS Change settings in entity?

There is a system in which I want to change the heath.hp parameter in the terget.entity entity. ArgumentException: The entity does not exist
when starting the application

public class AtackSystem : ComponentSystem
{

    protected override void OnUpdate()
    {
      Entities.ForEach((Entity entity,ref Damage damage,ref Target terget,ref Health heath)=>
      {
        float hpNow = heath.hp-(damage.damage*UnityEngine.Time.deltaTime);

          World.Active.EntityManager.SetComponentData<Health>(terget.entity, new Health {hp = hpNow});

      });


    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Devpiligrim, 2019-08-09
@Devpiligrim

Check if your heath exists when the script is executed...
In general, debugging is in your hands...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question