Quantcast
Viewing all articles
Browse latest Browse all 133

Help with Quaternion.Slerp movement?

Hey, I've been having some trouble with a quaterion.slerp code. I want the movement of my object to rotate based on the wasd key press. It works, for the most part. However, my object keeps rotating 90 degrees on the z-axis on play? ![alt text][1] I thought it was the model having the wrong axis forward, since it was imported from Blender, but that doesn't seem to have solved my problem. The code I used is below. I'm still a beginner at this stuff, so I'm wondering if it's something I did wrong? void Start() { controller = GetComponent(); } void Update() { moveDirection = new Vector3(Input.GetAxis("Horizontal") * moveSpeed, 0f, Input.GetAxis("Vertical") * moveSpeed); moveDirection.y = moveDirection.y + (Physics.gravity.y * gravityScale); transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(moveDirection), turnSpeed); controller.Move(moveDirection * Time.deltaTime); [1]: /storage/temp/135216-img2.png

Viewing all articles
Browse latest Browse all 133

Trending Articles



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