How to rotate actor left and right depending on how hard you tilt your phone
http_gamesalad
Member Posts: 1,340
I have an actor I want to rotate depending on the degree you tilt your phone .. BUT I don't want it to rotate more than 90° (to the left) and -90° (to the right) .. is this possible ?
Thank you in advance
Comments
@http_gamesalad Have you tried using the atan or asin functions? They limit the results between -90 and 90.
asin (Function): This is the trigonometric arcsine (inverse sine) function. Values for x should range from -1 to 1 with results from -90 to 90, respectively. Any other input values will result in ‘nan’.
atan (Function): This is the trigonometric arctangent (inverse tangent) function. Results will range from -90 to 90.
For a list of functions:
http://help.gamesalad.com/gamesalad-cookbook/1-getting-started/1-11-glossary/
Ah, your biannual asking of an accelerometer question Do you already have it set up so the actor rotates in response to tilting? Is it just the limiting to 90/-90 that you're asking about here, or the whole tilting thing too? Two questions with very different scope
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
@Armelline I have my actor set up to move (left and right) as you tilt your phone. (as shown here)
What I'm asking for is if theres a way to rotate the actor the same way but not letting it rotate more than 90 and -90 degrees . Do you understand now?
Bump?
Have you tried something like
RotateToAngle
Angle:min(45,max(-45,- self.Motion.Linear Velocity.X ))
Speed:300
Relative to:Scene
uncheck Run to Completion
uncheck Stops on Destination