#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# How to rotate actor left and right depending on how hard you tilt your phone

Posts: 1,340Member
edited October 2015

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 ?

• Posts: 779Member

@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:

• Posts: 4,760Member, PRO

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

• Posts: 1,340Member

@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?

• Posts: 1,340Member

Bump?

• Posts: 2,824Member, Sous Chef, PRO

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