private void ProcuraObstaculos() { Collider[] colliders = Physics.OverlapSphere(biarticulado.PosicaoReferencia().position, Mathf.Max(biarticulado.distanciaDeFrenagem, conAuto.dyn_distDeParada)); List <Semaforo> semaforos = new List <Semaforo>(); foreach (var item in colliders) { semaforoProximo = item.GetComponent <Semaforo>(); if (!semaforoProximo) { semaforoProximo = item.GetComponentInParent <Semaforo>(); } if (semaforoProximo) { semaforos.Add(semaforoProximo); } } FiltraSemaforos(semaforos); }
private void DefineSteeringAngle() { if (!biarticulado.wp_proximo || biarticulado.veiculoSendoParado) { horizontal = 0; return; } // calculate the local-relative position of the target, to steer towards Vector3 targetPos = biarticulado.PosicaoReferencia().InverseTransformPoint(biarticulado.wp_proximo.transform.position); // work out the local angle towards the target float targetAngle = Mathf.Atan2(targetPos.x, targetPos.z) * Mathf.Rad2Deg; // get the amount of steering needed to aim the car towards the target VALOR = targetAngle; horizontal = targetAngle / CVP_Calculos.MenorValor_SteeringAngle(biarticulado); horizontal = Mathf.Clamp(horizontal, -1, 1); // * Mathf.Sign(m_CarController.CurrentSpeed); }