Quantcast
Channel: Answers by "doomprodigy"
Viewing all articles
Browse latest Browse all 90

Answer by doomprodigy

$
0
0

I suggest using an int.

private int swingNum = 0;
private bool swinging = false;
public float swingTime = 2.0f;
void Update (){
if (Input.GetButtonDown("whatever")){
if (swinging == false){
 if (swingNum == 0){
 StartCoroutine("SwingOne");
 swingNum += 1;
 }
 if (swingNum == 1){
 StartCoroutine("SwingTwo");
 //from here onwards you would either add another digit to swingNum and put another
if statement asking if it is swingNum 2 or you would reset swing num to 0 again
Rinse and Repeat sort of deal`
    }
   }
  }
IEnumerator SwingOne () {
//do your rotation here
swinging = true;
yield return new WaitForSeconds(swingTime);
// return back to original position via your rotation or leave it where it has rotated to
swinging = false;
}
//Repeat the IEnumerator function with the different name and with different rotations etc

This is exactly what you want, you just need to fix the syntax and insert the rotations and swings.

Peace,

EDIT: You can also add a timer to how long it will wait until it reverts back to swing one if you don't click for ages while in between the second and third swing for instance.


Viewing all articles
Browse latest Browse all 90

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>