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

646
Views
Unity 3d, mi personaje no gira hasta el punto de Raycast que dibujé

Dibujo un riel en mi personaje central con la dirección del frente de mi cámara. Uso Rigidbody.LookRotation para hacer que el personaje regrese a ese punto, pero no es así.

 private void Update() { Physics.Raycast(transform.position + new Vector3(0, 3, 0), mainCam.transform.forward, out hit); Quaternion lookrotation = Quaternion.LookRotation(new Vector3(hit.point.x,0,hit.point.z)); transform.rotation = Quaternion.Slerp(transform.rotation, lookrotation, Time.deltaTime * 2); Debug.DrawLine(transform.position + new Vector3(0, 3, 0),hit.point); Debug.Log(hit.collider.gameObject.name); }

Mi escena

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

A primera vista hay dos puntos:

  1. LookRotation espera una dirección de avance... actualmente solo le das una posición .

    preferirías usar, por ejemplo

     if(Physics.Raycast(transform.position + new Vector3(0, 3, 0), mainCam.transform.forward, out var hit)) { var direction = hit.point - transform.position; direction.y = 0; var lookrotation = Quaternion.LookRotation(direction); ... }
  2. actualmente también giras muy lento. Asumiendo 60 Fps Cada fotograma que interpola con un factor de aproximadamente 1/60 * 2 , por lo que aproximadamente 0.033.. desde la rotación actual hacia la rotación objetivo. Entonces, esto se vuelve aún más lento cuanto más te acercas a la rotación objetivo.

    Preferiría no multiplicar por Time.deltaTime sino usar un factor constante, por ejemplo, 0.5f

    o use RotateTowards y proporcione un continuo anglePerSecond * Time.deltaTime .

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!