Jump to content

is there any way to register a full backflip (360 degree rotation) in code, and reward points accordingly?


kriket
 Share

Recommended Posts

I have this physics-based car game where I want to reward points for a full backflip (360 rotation) of the car when in the air. The car can backflip just fine under physics, but I dont know how to record one backflip, for example. How can I go about getting this done? Any pointers. 

 

Appreciate it.

Link to comment
Share on other sites

Let's suppose that a backflip can only happen when the car is off the ground - in this case, you can store the angle of the car when it is taking off, then incrementally compare its angle with a few fractions of 360 (plus the initial angle) - maybe at least two or three. Then check the angle in the update and if it passes the first increment (e.g. 120 in case there are three), raise a flag, if it then also passes the second one (e.g. 240), raise a second flag, and if at the end the angle is 0 and the flags are still raised, you've most probably done a full rotation. If it happens that you can rotate the car back and forth, you may also need to lower the flag if for example the car rotates past 120 degrees and then back.

 

P.S. Now that I think of it, it may work with only one check (at 180 degrees), but I haven't tried it.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...