Exemple #1
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        float  dT        = Time.DeltaTime;
        float3 targetPos = (float3)GameManagers.GetPlayerPosition();

        var jobHandle = Entities.WithName("SearchSystem").ForEach((ref PhysicsVelocity phys, ref Translation trans, ref Rotation rot, ref MovementData mData) =>
        {
            float3 dir = targetPos - trans.Value;
            rot.Value  = quaternion.LookRotation(dir, math.up());
        }).Schedule(inputDeps);

        return(jobHandle);
    }
Exemple #2
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        NativeArray <float3> launcherPositions = new NativeArray <float3>(GameManagers.instance.launcherPositions, Allocator.TempJob);
        float3        playerPos = GameManagers.GetPlayerPosition();
        EntityManager em        = this.EntityManager;

        Entities.WithoutBurst().WithStructuralChanges().ForEach((Entity entity, ref Translation pos, ref Rotation rot, ref EnemyData eData) =>
        {
            //foreach (float3 launcherPos in launcherPositions)
            //{
            var laserInstance = em.Instantiate(eData.enemyLaser);
            em.SetComponentData(laserInstance, new Translation {
                Value = pos.Value                                                     /* + math.mul(rot.Value, launcherPos)*/
            });
            em.SetComponentData(laserInstance, new Rotation {
                Value = rot.Value
            });
            //}
        }).Run();

        launcherPositions.Dispose();
        return(inputDeps);
    }