I am making this game in which the player controls an object by steering it left right (the object always moves forward).
Now if the player makes the object go in a circle (the object makes a loop) then the player should get points for that. So I need a way to detect if the object has moved in a circle (a complete circle or close to it, say more than 300 degrees).
I was hoping somebody would have an idea on how to do this or know where I can find information on how to do this (I’ve been searching the web but could not find anything yet)…
First thing that comes to mind is time the amount of a left or right turn Input and compare that to how long it would take to make a full circle. If you’ve held down left or right long enough, then you get points.
I was personally thinking about checking the change in orientation of the forward-vector of the object over time to see if it changed more than 300 degrees in one direction.
Your sollution is pretty similar but probably easier to implement
I consulted a collegue of mine (an actual game programmer, not a game designer like me and he gave me a nice tip!
It’s a little bit brute force and simplistic but it works:
I created a number of “sensors”, in my case 5 sensors, that are equally spaced in a circle. In my case like this:
sensor 1 at 0 degrees
sensor 2 at 72 degrees
sensor 3 at 144 degrees
sensor 4 at 216 degrees
sensor 5 at 288 degrees
each sensor can have 3 values: “none”, “left” or “right”
whenever the object’s orientation “passes by” one of the sensors then it checks if it was passed from the lef or the right and sets the sensor accordingly.
Whenever I detect that say… all 5 sensors are set to “left” then apparently the object made a full circle! When that happens I reset the sensors and start over again…
simple, but it works!
The method of reading the input would not have worked because the object could get stuck against a wall or so: the input then continues but the object does not rotate.