want to control "tilt" but only a 30 degree tilt with Accelerometer

part12studiospart12studios Member Posts: 620
edited April 2012 in Working with GS (Mac)
Hi everyone,

So i've done some things in the past with the accelerometer and i know how to tilt things to go left or right.. like say.. a cup with an ball in it. like to "pour" something out.. by tilting left or right..

however what i couldn't seem to achieve is how to control how much tilt is acknowledged.. if i only want the cup to tilt 30 degrees rather than it being 180 degrees.. i would imagine contraints would work but i couldn't figure out how to use a constraint or two to control the range..

any tips / advise would be greatly appreciated!

Thanks!
Caleb

Best Answer

  • tatiangtatiang Posts: 11,949
    edited April 2012 Accepted Answer
    I would convert the accelerometer value into a value you want to work with. So you could rotate/tilt your device with a Display Text actor to show the values (x, y, and/or z) and see at what point 30° is. Let's say it's when the x value is 0.4. Then give your actor an attribute (type real) self.accelX and constrain that to between -0.4 and 0.4. You can then work with self.accelX however you normally would use the accelerometer's actual x value.

    Here, I created a demo: http://dl.dropbox.com/u/19602014/Constrain Tilt Angle.zip

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Answers

  • part12studiospart12studios Member Posts: 620
    ah ok thats cool. i've never used Max / Min before.. i assumed i'd have to use several constraints, but that wasn't working for me.. i'll definitely give that a try tomorrow! but first i must sleep and approach this with a clear head
Sign In or Register to comment.