how to set a rotation without it constantly rotating?
I'm trying to set an object's rotation without it constantly rotating. Say there's a float for the rotation's value, if that float is at 90, I want the object to stay at 90 degrees, not rotate 90 degrees constantly causing a headache to anyone who sees it. I'm coding in C# so if it's possible you can help me in that language I'd appreciate it, trying to keep things constant.
!!!EDIT 10-23-2015!!! I'm trying to make the object's rotation relative to the minute of the hour.
!!!EDIT 11-3-2015!!! Okay, scratch the minute of day thing, I need it relative to real time.
I guess you used someting like this:
transform.Rotate(Vector3.right * Time.deltaTime);
what you need is:
transform.rotation = Quaternion.Euler(0, 30, 0);
That didn't quite work, but it's closer than I was before
Do you need something like : float speed = 10.0f; float targetYAngle = 30; transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.Euler(0, targetYAngle, 0), Time.time * speed);
Answer by DiegoSLTS · Oct 23, 2015 at 12:46 PM
You're probably changing the rotation inside the Update or LateUpdate methods, just move the code somewhere that's called only once. If this is not your case then share the code you're using.
If you want a smooth rotation you can use a coroutine and the Rotate method, or do it in Update but inside an if that checks if the object needs to be rotated.
Forgot to mention it early, I'm trying to make it change every so and so real life $$anonymous$$utes. I'll try a little something like that and if it doesn't work I'll try Toromano's method
Answer by Statement · Oct 24, 2015 at 12:11 AM
Somewhat, but ins$$anonymous$$d of an object, I want to rotate a light, and I want it to be as close to real time as possible, so if it's dark where the player is it's night where the player is it's night in game or day where the player is means day in game.
Your answer
