Question by 
               RogueMacro · Mar 29, 2019 at 07:30 PM · 
                unity 5errorchunksiterate  
              
 
              ComponentChunkIterator is not liking me..
So, I was just minding my own business when unity suddenly gave me a NullReferenceError: Unity.Entities.ComponentChunkIterator.MoveToEntityIndex:
Here: Unity.Entities/Iterators/ComponentChunkIterator.cs:463 Is there something I could have done wrong?
Here the code it is referencing to (At the foreach loop in OnUpdate -> line 31):
 using UnityEngine;
 using Unity.Entities;
 
 public class SelfDestroy : MonoBehaviour
 {
     public float delay = 5f;
     public float timeLeft;
 
 }
 
 class SelfDestroyer : ComponentSystem
 {
     struct Components
     {
         public SelfDestroy destroy;
         public Transform transform;
     }
 
     protected override void OnStartRunning()
     {
         foreach (var entity in GetEntities<Components>())
         {
             entity.destroy.timeLeft = entity.destroy.delay;
         }
     }
 
     protected override void OnUpdate()
     {
         float deltaTime = Time.deltaTime;
 
         foreach (var entity in GetEntities<Components>())
         {
             if (entity.destroy.timeLeft <= 0f)
             {
                 Object.Destroy(entity.transform.gameObject);
             }
             else
             {
                 entity.destroy.timeLeft -= deltaTime;
             }
         }
     }
 }
 
              
               Comment
              
 
               
              Your answer