- Home /
Know if an object has been rotating 180 or 360 degrees?
So im making this sidescrolling-skate thing and i just figured out how to make my player rotate. I've also figured out how to make it so when my player lands in a crooked angle it activates a crash function. What im trying to figure out now is how to activate a bool called "switch" (that's what it called when you ride a skateboard in the opposite stance) whenever it only rotates a 180 degrees (in my case somewhere between 166 and 194 to make some room for mistakes) and deactivate it when its back to normal or if you do a full 360. It works for the 180 degrees and my switch bool gets activated, but when i try to do the same thing for a full 360 rotation it doesn't work like i want it to.
Here is my code:
 if (grounded && modelTranform.transform.eulerAngles.y >= 15 && modelTranform.transform.eulerAngles.y <= 165) {
             Crash ();
         }
         if (grounded && modelTranform.transform.eulerAngles.y >= 195 && modelTranform.transform.eulerAngles.y <= 345) {
             Crash ();
         }
         if (grounded && modelTranform.transform.eulerAngles.y <= 14 && modelTranform.transform.eulerAngles.y >= 346) {
             Debug.Log ("no switch");
             switchStance = false;
             modelTranform.transform.localEulerAngles = new Vector3 (0, 0, 0);
         } 
         if (grounded && modelTranform.transform.eulerAngles.y >= 166 && modelTranform.transform.eulerAngles.y <= 194) {
             Debug.Log ("switch");
             switchStance = true;
             modelTranform.transform.localEulerAngles = new Vector3 (0, 180, 0);
         } 
Your answer
 
 
             Follow this Question
Related Questions
Flip over an object (smooth transition) 3 Answers
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer
Grid-based game movement 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                