Beispiel #1
0
 void Start()
 {
     animator           = GetComponentInChildren <Animator>();
     enemy              = GetComponent <EnemyLOS2D>();
     enemy.onDeath     += OnDeath;
     enemy.onSeeTarget += OnSeen;
 }
Beispiel #2
0
        private void OnCollisionEnter2D(Collision2D other)
        {
            EnemyLOS2D enemy_other = other.gameObject.GetComponent <EnemyLOS2D>();

            if (enemy_other)
            {
                if (state == EnemyLOS2DState.Patrol && enemy_other.state == EnemyLOS2DState.Chase)
                {
                    VisionTarget target = enemy_other.seen_character;
                    if (target)
                    {
                        ChangeState(EnemyLOS2DState.Chase);
                        enemy_follow.target = target.gameObject;
                        seen_character      = target;
                    }
                }
            }
        }