예제 #1
0
    private void updateLkp(PerceptionEntry entry)
    {
        // Can see target
        float angleToTarget = Vector3.Angle(entry.boxCollider.bounds.center - self.getHeadPosition(), self.transform.forward);

        if (angleToTarget <= self.getFov() / 2 &&
            (entry.boxCollider.bounds.center - self.getHeadPosition()).magnitude <= self.getSighDistance() &&
            hasLineOfSight(entry.boxCollider))
        {
            entry.lkp          = entry.animal.transform.position;
            entry.isLkpValid   = true;
            entry.lkpTimeStamp = Time.time;
            return;
        }

        // Can see lkp (but not on target)
        float angleToLkp = Vector3.Angle(entry.lkp - self.getHeadPosition(), self.transform.forward);

        if (angleToLkp <= self.getFov() / 2 &&
            (entry.lkp - self.getHeadPosition()).magnitude <= self.getLkpSightDistance() &&
            hasLineOfSight(entry.lkp))
        {
            entry.isLkpValid   = false;
            entry.lkpTimeStamp = float.MinValue;
            return;
        }

        if (entry.lkpTimeStamp + entry.animal.getLkpExpire() <= Time.time)
        {
            entry.isLkpValid   = false;
            entry.lkpTimeStamp = float.MinValue;
            return;
        }
    }