Howdy, Stranger!

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

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

part12studiospart12studios Posts: 619Member
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!


Best Answer

  • tatiangtatiang Posts: 11,845Member, Sous Chef, PRO, Senior Sous-Chef
    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: Tilt

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


  • part12studiospart12studios Posts: 619Member
    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
This discussion has been closed.