Shooter Problem
betazero
Member Posts: 39
I have an actor which has a turret on top that rotates to the mouse position. It works fine except for when I tap the perfect 0 on the screen relative to the actor. It wants to spin 360 degrees to get to that point. Its not the worst thing in the world but it annoys me. Any way to work around this? am I doing something wrong?
Comments
if angle = 0 ... don't spin ... otherwise ... spin to location/angle
The above is a principle of logic...not an actual implementation.
Set up a rule that achieves the above principle
You may want to take the expression you are using for the turret to "track" the mouse and simply add parenthesis around it and then modulus that by 360. It maybe interpreting zero as 360 and thus the unnecessary spin. The modulus would make sure it is zero if the value was 360. But given the beta nature of GS, it may very well be interpreting 0 (while at 0) as go ahead and spin anyway. ;-)
on touch - get the new touch position angle relative to turret center (which might require some trig calcs...that ARCSIN, ARCCOS, ARCTAN stuff)
RULES:
when newTouchAimingAngle is < currentGunAngle
AND
currentGunAngle is < 180
.......spin clockwise
otherwise
.......when newTouchAimingAngle is < currentGunAngle + 180
..............spin clockwise
.......otherwise
..............spin counter clockwise
Then set up rules to rotate clockwise or counterclockwise within that structure