Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int dir = 1; // somewhere global
- Quaternion r = Quaternion.Euler(0, Timer.deltaTime * dir, 0);
- transform.rotation *= r;
- // I want to: if the "angle is >= 5f", i want to do dir *= -1 to reverse it
- if (/* angle delta is >= 5f or <= -5f */)
- {
- dir *= -1;
- }
- public class rotator : MonoBehaviour {
- public float _Angle;
- public float _Period;
- private float _Time;
- // Update is called once per frame
- void Update () {
- _Time = _Time + Time.deltaTime;
- float phase = Mathf.Sin(_Time / _Period);
- transform.localRotation = Quaternion.Euler( new Vector3(0, phase * _Angle, 0));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement