- Home /
Question by
Ogreboy · Feb 01 at 07:45 PM ·
rotate object
Why doesn't maxDegreesDelta matter in my RotateTowards?
I'm trying to get my gameobject to rotate slower than the input. If I use Quaternion.RotateTowards, it doesn't matter what I put in for maxDegreesDelta (it can be 0, it can be 1000, it can be multiplied by Time.deltaTime or by Time, or by a counter...) The rotation is always exactly as fast as the input. The same thing happens when I use Quaternion.Slerp... time simply doesn't matter. What am I missing?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class cubetest : MonoBehaviour
{
Transform destinationRotation;
public float rotationSensitivity = 1;
public float rotationSpeed = 1;
// Start is called before the first frame update
void Start()
{
destinationRotation = transform;
}
// Update is called once per frame
void Update()
{
if (Input.GetAxis("Mouse X") != 0)
{
destinationRotation.Rotate(0, Input.GetAxis("Mouse X") * rotationSensitivity, 0, Space.World);
}
transform.rotation = Quaternion.RotateTowards(transform.rotation, destinationRotation.rotation, rotationSpeed * Time.deltaTime);
}
}
Comment
Answer by Ogreboy · Feb 01 at 08:01 PM
...it's something about my destinationRotation Transform. If I use an actual GameObject rather than a Transform, it works as intended. :P
Your answer