Esempio n. 1
0
    private void LateralCheck()
    {
        float _distance, _MyPosXAbs, _OthPosXAbs;

        _MyPosXAbs  = System.Math.Abs(ThisNPC.transform.position.x);
        _OthPosXAbs = System.Math.Abs(OtherNPC.transform.position.x);
        _distance   = _MyPosXAbs - _OthPosXAbs;
        if (_distance > (ThisNPC.GetComponent <CapsuleCollider>().bounds.size.x + 0.5f))
        {
            ThisNPC.GetComponent <Animator>().SetTrigger("Overtaken");
        }
    }
Esempio n. 2
0
 private void CheckOvertake(NPCMoveTest _other)
 {
     if (_other != null)
     {
         float _distance = Vector3.Distance(ThisNPC.transform.position, _other.transform.position);
         if ((_distance > 5f && !_other.Overtaking) || _other.direction == ThisNPC.direction)
         {
             ThisNPC.OvertakeZone = _OvertakeZone;
             ThisNPC.GetComponent <Animator>().SetBool("CanOvertake", true);
         }
     }
     else
     {
         ThisNPC.OvertakeZone = _OvertakeZone;
         ThisNPC.GetComponent <Animator>().SetBool("CanOvertake", true);
     }
 }
Esempio n. 3
0
    // OnStateExit is called when a transition ends and the state machine finishes evaluating this state
    //override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    //{
    //
    //}

    private void CheckDistance()
    {
        RaycastHit _hit;

        if (Physics.Raycast(ThisNPC.transform.position, new Vector3(ThisNPC.direction, 0), out _hit, 5f))
        {
            if (_hit.transform.GetComponent <NPCMoveTest>() != null)
            {
                float _distance = Vector3.Distance(ThisNPC.transform.position, _hit.transform.position);
                ThisNPC.GetComponent <Animator>().SetFloat("Distanza", _distance);
            }
        }
    }