Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

199
Views
Información de ángulo (grados) entre la cámara AR y el objeto objetivo en un avión

Tengo una pregunta, por favor ayuda y gracias! Quiero saber cómo mostrar la información de ángulo (grado) entre la cámara AR y el objeto de destino en un avión. (Usando un teléfono inteligente) Y quiero saber cómo "codificar" con Unity y AR Foundation.

Intenté usar un código (a continuación), pero parece que solo funciona en Distancia, no funciona en Ángulo ...

¡Gracias de nuevo!

 void Start () { //get the components private ARRaycastManager RayManager; private GameObject visual; public Camera CameraStart; public Text textField2; public Text textField; float distance; float angle; RayManager = FindObjectOfType<ARRaycastManager>(); visual = transform.GetChild(0).gameObject; } void Update () { // shoot a raycast from the center of the screen List<ARRaycastHit> hits = new List<ARRaycastHit>(); RayManager.Raycast(new Vector2(Screen.width / 2, Screen.height / 2), hits, TrackableType.Planes); RaycastHit hit; //Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); // check if we hit an AR plane, update the position and rotation if(hits.Count > 0) { transform.position = hits[0].pose.position; transform.rotation = hits[0].pose.rotation; distance = Vector3.Distance(CameraStart.transform.position, transform.position); textField.text = distance.ToString("N2") + "meter"; Physics.Raycast(transform.position, out hit); angle = Vector3.Angle(hit.normal, transform.forward); textField2.text = angle.ToString("N2") + "degree"; if(!visual.activeInHierarchy) visual.SetActive(true); } }

}

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Comprobaría que el rayo incide:

 if (Physics.Raycast(transform.position, out hit)) { angle = Vector3.Angle(hit.normal, transform.forward); textField2.text = angle.ToString("N2") + "degree"; } else { Debug.LogError("Did not hit") }

También me aseguraría de que el objetivo tenga un colisionador y que la máscara de capa sea correcta.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!