want to control "tilt" but only a 30 degree tilt with Accelerometer
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
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
-
tatiang Posts: 11,949
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.zipNew to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Answers