How to check if player is rapidly rotating the joystick?
Currently working on a game that needs a check to see if the player is rotating the joystick around in a circular motion. That is, they are quickly rotating it around a few times, like spinning a spinner. The first major example that comes to my head is in the old Paper Mario game in which you twirl the joystick around a few times to flip your character around to get into small spaces. I thought of doing a check to see if the player inputs a certain direction, and then within a timer checking to see if they input the "next" direction (downleft if they had previously put in down) etc... a few times, but this just seems like a really inefficient way to do this. Any better methods out there? Any help would be greatly appreciated!
Answer by areTeam · Jan 12, 2019 at 10:07 PM
I'm need similiar so I try making; https://answers.unity.com/questions/604536/is-there-a-magic-code-for-getting-delta-values.html from the basic
     public float deltaY;
     public float deltaX;
     float oldX;
     float oldY;
     public int rotatecount;
     public float MinRotSpd;
     Vector2 inputdirect;
     void Update()
     {
         
         float deltaValuex = Input.GetAxisRaw("Horizontal") - oldX;
         float deltaValuey = Input.GetAxisRaw("Vertical") - oldY;
         oldX = Input.GetAxisRaw("Horizontal");
         oldY = Input.GetAxisRaw("Vertical");
         if(Mathf.Abs(deltaValuex) < MinRotSpd && Mathf.Abs(deltaValuey) < MinRotSpd)
         {
             rotatecount = 0;
             inputdirect = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
         }
         if (Mathf.Abs(deltaValuex) >= MinRotSpd || Mathf.Abs(deltaValuey) >= MinRotSpd)
         {
             inputdirect = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
             if (Input.GetAxisRaw("Horizontal") == inputdirect.x && Input.GetAxisRaw("Vertical") == inputdirect.y)
             {
                 rotatecount += 1;
             }
             if(rotatecount >= 2)
             {
                 //place here your action if you like work similar to super mario odyssey
                 DoSpin();
             }
             //or palace here if you like instant
         }
     }
     void DoSpin()
     {
         //action
     }
 
               I hope helped this
Your answer
 
             Follow this Question
Related Questions
Stuck inside of Composite Collider when using Platform Effector 2D 2 Answers
I can't make transition from actual animation to previous one 1 Answer
dash till puff game 0 Answers
Storing playerprefs as string in inputfield.text 1 Answer
"Object reference not set to the instance of an object" 0 Answers