- Home /
Question by
AdamOcheri · May 17, 2020 at 08:47 AM ·
rotationquaternionfloatautomation
Help! Stuck with this rotation automation! I got this automation to work for position and localScale, but them damn Quaternions...
everything in the code reads out fine except for the line
Quaternion sineWave = Mathf.Sin (cycles * tau);
It says I cannot implicitly convert type float to quaternion. Any ideas? Even the tinniest insight would be greatly appreciated! :)
public class Oscillator3 : MonoBehaviour
{
[SerializeField] Quaternion rotationScale;
[Range(0, 1f)] [SerializeField] Quaternion rotationLever;
[SerializeField] float period;
Quaternion initRotation;
void Start()
{
initRotation = transform.rotation;
}
void Update()
{
float cycles = Time.time / period;
const float tau = Mathf.PI * 2;
Quaternion sineWave = Mathf.Sin(cycles * tau);
rotationLever = sineWave;
Quaternion rotAmount = rotationLever * rotationScale;
transform.rotation = initRotation * rotAmount;
}
Comment
Your answer

Follow this Question
Related Questions
Bone Rotation on X (or any) axis Issues 1 Answer
Unity thinks my Quaternion is a Float 2 Answers
Rotation relations and EulerAngles's mess 0 Answers
How can i sync the rotation of players (clients) on a dedicated server? 0 Answers
Rotating a 3D object relative to it's velocity, but only on a 2D plane 0 Answers