Beispiel #1
0
    private void ForwNBackCheck(ZonaPedonale _zona)
    {
        _OvertakeZone = _zona;
        Vector3 RayStartPos = new Vector3(_zona.transform.position.x, ThisNPC.transform.position.y, _zona.transform.position.z);

        Debug.DrawRay(RayStartPos, Vector3.left * 50, Color.green);
        Debug.DrawRay(RayStartPos, Vector3.right * 50, Color.green);
        RaycastHit _hit;

        if (Physics.Raycast(RayStartPos, Vector3.left, out _hit, 50f))
        {
            if (_hit.transform.GetComponent <NPCMoveTest>() != null)
            {
                _others.Add(_hit.transform.GetComponent <NPCMoveTest>());
            }
        }
        if (Physics.Raycast(RayStartPos, Vector3.right, out _hit, 50f))
        {
            if (_hit.transform.GetComponent <NPCMoveTest>() != null)
            {
                _others.Add(_hit.transform.GetComponent <NPCMoveTest>());
            }
        }
        if (_others.Count == 0)
        {
            CheckOvertake(null);
        }
        else
        {
            foreach (NPCMoveTest _other in _others)
            {
                CheckOvertake(_other);
            }
        }
    }
Beispiel #2
0
    private void LateralCheck(ZonaPedonale _zona)
    {
        float _direction = _zona.transform.position.z - ThisNPC.transform.position.z;

        Debug.DrawRay(ThisNPC.transform.position, new Vector3(0, 0, _direction), Color.blue);
        RaycastHit _hit;

        if (!Physics.Raycast(ThisNPC.transform.position, new Vector3(0, 0, _direction), out _hit, 1.4f) || _hit.transform.GetComponent <NPCMoveTest>() == null)
        {
            ForwNBackCheck(_zona);
        }
    }