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

http_gamesaladhttp_gamesalad Member Posts: 1,340
edited October 2015 in Working with GS (PC)

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

  • FrantoFranto Member Posts: 779

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

  • ArmellineArmelline Member, PRO Posts: 5,354

    Ah, your biannual asking of an accelerometer question :D 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 :D

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

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

  • http_gamesaladhttp_gamesalad Member Posts: 1,340

    Bump?

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    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

Sign In or Register to comment.