Quantcast
Channel: Questions in topic: "issue"
Viewing all articles
Browse latest Browse all 827

Quaternion Rotation On Specific Axis Issue

$
0
0
Hello there, I try to rotate a cube and I use quaternations, it works correctly on y axis but not working properly on x axis (Horizontal) hope you guys can help. public class NewBehaviourScript : MonoBehaviour { public Transform player; Vector3 currentRot; Quaternion rotation; // Use this for initialization void Start() { } // Update is called once per frame void Update() { currentRot = new Vector3(transform.eulerAngles.x, transform.eulerAngles.y, transform.eulerAngles.z); if (Swipe.Instance.IsSwiping(SwipeDirection.Left)) { // Debug.Log("Entered Correctly Left"); Debug.Log(currentRot); currentRot.y += 90; rotation = Quaternion.Euler(currentRot); } else if (Swipe.Instance.IsSwiping(SwipeDirection.Right)) { // Debug.Log("Entered Correctly Right"); Debug.Log(currentRot); currentRot.y -= 90; rotation = Quaternion.Euler(currentRot); } else if (Swipe.Instance.IsSwiping(SwipeDirection.Up)) { // Debug.Log("Entered Correctly Up"); Debug.Log(currentRot); // currentRot.z += 90; currentRot.x += 90; rotation = Quaternion.Euler(currentRot); } else if (Swipe.Instance.IsSwiping(SwipeDirection.Down)) { // Debug.Log("Entered Correctly Down"); Debug.Log(currentRot); // currentRot.z -= 90; currentRot.x -= 90; rotation = Quaternion.Euler(currentRot); } transform.rotation = Quaternion.LerpUnclamped(transform.rotation, rotation, 0.01f * 10); } } ![alt text][1] [1]: /storage/temp/113235-cuberotation.gif

Viewing all articles
Browse latest Browse all 827

Trending Articles



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