Rotation not working
Hey guys! creeperbot65 here! (Second time trying to write this post)
I'm having problems with the rotation of a hand for a clock. It's supposed to rotate the seconds time on my computer * 6 but when I do that to the X and Y axis, they go to 0 no matter what I do and the Z axis turns around to 66.61 degrees and I can't change that either.
Here's my code: using System.Collections; using System.Collections.Generic; using UnityEngine;
public class ClockHand : MonoBehaviour {
public int Seconds;
public Transform Clock;
void FixedUpdate () {
if (tag == "SecHand") {
Seconds = System.DateTime.Now.Second;
Quaternion temp = Clock.rotation;
temp.y = Seconds * 6;
temp.x = Seconds * 6;
temp.z = 0;
temp.w = 0;
transform.rotation = temp;
}
}
}
Before the game starts or when the seconds on my computer clock is 0
After game starts and my computer timer is not at 0
howtheclockisatthestart.jpg
(14.6 kB)
howtheclockis.jpg
(14.5 kB)
Comment
$$anonymous$$anipulating a quaternion's properties directly is hard for most people. You should try another way. Transform.Rotate() looks like a method that could do what you're asking.