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

427
Views
Unidad: se agregó un desplazamiento adicional al mirar hacia el objetivo, ¿tal vez la diferencia entre Rotate () vs transform.rotation?

Estoy confundido si usar Rotate() y .rotation entrarán en conflicto entre sí.

Estoy moviendo una transformación para apuntar a un objetivo automáticamente con .rotation y cuando elijo mover manualmente, uso Rotate(). Pero después de detener el control manual y usar el modo automático, la transformación se compensará con el movimiento manual que había hecho. Entonces Rotate() está agregando desplazamiento. El control manual no importa lo que sea preciso. La orientación automática se agrega un desplazamiento después de usar el control manual.

Aquí está el código para el control manual.

 xDif = Input.GetAxis("Mouse X") * mouseSensitivity.x; yDif = -Input.GetAxis("Mouse Y") * mouseSensitivity.y; float zDif = 0; // <-- gets changed with buttons transformToMove.Rotate(new Vector3(yDif, xDif, zDif));

Aquí está el código para la segmentación automática

 /// Returns true if the transform has been successfully oriented to fire at the current target. private bool TrackTarget(out Vector3 hitPosition, out float hitTime) { hitPosition = Vector3.zero; hitTime = -1.0f; if (!IsTargetValid(currentTarget)) { state = TransformState.NoTarget; return false; } if (!GetFiringDirectionToHitTarget(currentTarget, out Vector3 firingDirection, out hitPosition, out hitTime)) { return false; } Quaternion desiredRotation = Quaternion.LookRotation(invertFiringDirection ? -firingDirection : firingDirection); Quaternion currentRotation = transformToMove.rotation; float maxDeltaAngle = maxRotationDegreesPerSecond * Time.fixedDeltaTime; transformToMove2.rotation = Quaternion.RotateTowards( currentRotation, desiredRotation, maxDeltaAngle );
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Parece que la variable desiredRotation está siendo influenciada por la rotación actual del jugador. Su desiredRotation se establece en función de LookRotation() de una dirección de firingDirection . ¿Su método GetFiringDirectionToHitTarget() está usando la posición actual del jugador, por casualidad?

over 4 years ago · Santiago Trujillo Report

0

Básicamente fue un error "estúpido". En mi control manual, estaba aplicando la rotación a transformToMove y en el Editor se aplicó a un elemento secundario de la transformación principal. Entonces, obviamente, habría un desplazamiento si la rotación inicial es para el padre ( transformToMove2 ).

Perdón por esto, dejaré la publicación para enseñar Unity e incluso programadores en el futuro. Que no importa cuántas veces revise su código y lo refactorice, la solución puede estar justo frente a sus ojos. Por ejemplo, usando la transformación incorrecta...

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!