How can I set a toggle to reverse the direction of a rotation?
Hello,
I'm trying to set a Toggle to reverse the rotation of a spinning radar.
My current method that I 'm attempting is to switch from:
transform.Rotate (Vector3.back, (BPM / 240 360 Time.deltaTime));
to
transform.Rotate (Vector3.forward, (BPM / 240 360 Time.deltaTime));
This occurs on update, causing a clock line / "radar" to rotate at a 'BPM'/music tempo speed.
So far I've created 2 dynamic booleans to be toggled: RadarReverseState and RadarForwardState
I'm having trouble coding an " if / else " statement which would switch the direction, one state turning on as the other turns off.
OR Is there a different method I could use to achieve this?
Any input is greatly appreciated.
public class radarScript : MonoBehaviour {
 // holds the BPM display value, for use with the slider UI
 public float BPM = 10f;
 public UnityEngine.UI.Text displayBPM;
 public int BPMdisplay;
 public void RadarForwardState(bool radarForward)
 {
     Debug.Log ("Radar Reverse Activation Button pressed");
     {
         transform.Rotate (Vector3.back, (BPM / 240 * 360 * Time.deltaTime));
     }
 }
 public void RadarReverseState(bool radarReverse)
 {
     Debug.Log ("Radar Reverse Activation Button pressed");
     {
         transform.Rotate (Vector3.forward, (BPM / 240 * 360 * Time.deltaTime));
     }
 }
 public void AdjustSpeed(float newSpeed)
 {
     BPM = newSpeed; 
     displayBPM.text = BPM.ToString();
 }
 // Update is called once per frame
 void Update ()
 {
     
     transform.Rotate (Vector3.back, (BPM / 240 * 360 * Time.deltaTime));
     }
}
Your answer
 
 
             Follow this Question
Related Questions
How to use WaitForSeconds? 2 Answers
Toggle Gravity on button press 1 Answer
toggle button blinks 1 Answer
Rotation with limits not working? 1 Answer
Rotate while Boolean=true 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                