2D-Platformer/Assets/Scripts/Systems/ProjectileSystem.cs
2022-02-12 12:53:50 +02:00

18 lines
No EOL
382 B
C#

using Unity.Entities;
using UnityEngine;
public class ProjectileRemoveSystem : ComponentSystem
{
protected override void OnUpdate()
{
Entities.ForEach(
(Entity entity, Transform transform, ref ProjectileData projectile) =>
{
if (projectile.Life <= 0)
{
Object.Destroy(transform.gameObject);
PostUpdateCommands.DestroyEntity(entity);
}
});
}
}