Quantcast
Channel: Latest Questions by S_Darkwell
Viewing all articles
Browse latest Browse all 40

Per-Axis (Euler) Rotation Control While Avoiding Gimbal Lock

$
0
0
I am writing a target-following script with numerous per-axis settings. Below is the most distilled example I can provide of the rotation portion: private void Rotate() { var _target = Quaternion.LookRotation(Target.position - transform.position, Target.up).eulerAngles; var _next = transform.eulerAngles; for (var i = 0; i < 3; i++) _next[i] = Mathf.LerpAngle(_next[i], _target[i], smoothRotateSpeed[i] * Time.deltaTime); transform.localRotation = Quaternion.Euler(_next); } In the example above, "smoothRotationSpeed" is a Vector3 that applies a different smoothing value to each axis. Unfortunately, because I am modifying each axis individually, I am running into Gimbal lock issues. How can one avoid or compensate for Gimbal lock without losing per-axis (euler) control?

Viewing all articles
Browse latest Browse all 40

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>