how do i tilt gravity in realtime? like tilting over a stack of boxes..

part12studiospart12studios Member Posts: 620
edited December 2011 in Working with GS (Mac)
I know there have been threads in the past, but I can't find them when I use the search field.. so yea I'm wondering how i can use the accelerometer to shift gravity of objects in realtime

I've made some attempts at it, but i'm having trouble with the tilting not updating continously.. it seems like when i tilt to the left or the right i get a single register but thats it.

I have some ideas to go beyond this, but really I just think my methods (like stacking numerous rules with range values being terribly inefficient and potentially performance hindering.

Thanks!
Caleb

Comments

  • part12studiospart12studios Member Posts: 620
    edited December 2011
    yea thats what i mean.. using that. i know how to access it.. but its just an ongoing series of values from 0.0 - 1.0 for x y and z. the point is to continuously update the game values to use the accelerometer values to update into meaningful values for things like direction of a given behavior
  • part12studiospart12studios Member Posts: 620
    edited December 2011
    what would people suggest is a best method for doing a tilt / physics system? The issue i'm having is getting the accelerometers continuous feed to consistently update the accelerate behavior / direction... but maybe there is a better way to achieve this altogether?
  • part12studiospart12studios Member Posts: 620
    just so there is no doubt.. here is a perfect example
  • TumbleSoftTumbleSoft Member Posts: 63
    Turn off gravity in all of your actors you want to move with the accelerometer. Then Accelerate with the angle being Vector to Angle (accelerometer x, accelerometer y)

    Hope this helps.
  • LeonardDeveloperLeonardDeveloper Member Posts: 4,630
    @part12studios
    This type of physics is called "Sandbox" I don't think it can be accomplished fully with GS, maybe in the future...
    ---------------
    Posted by LeonardDeveloper, contact me on thermoapps@thermo-apps.com
    Be sure to visit my WEBSITE
    Have a look at my GS Tutorials
    Image and video hosting by TinyPic
    ----------------------------------------------------
  • part12studiospart12studios Member Posts: 620
    edited December 2011
    ok here is the project i built so far.. what i'm trying to do is have the stuff shift to the left and right with the accelerometer..

    http://www.part12studios.com/Temp/Water_Test_1.gameproj.zip

    its ugly but its how i'm trying to get the tilt to work.. perhaps someone can see a better way so when tilting left or right the balls continue to drift downward..

    another question that would probably answer the same question in a different way would be how to do a labyrinth style game like this:
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    @part12studios said:
    ok here is the project i built so far.. what i'm trying to do is have the stuff shift to the left and right with the accelerometer..

    http://www.part12studios.com/Temp/Water_Test_1.gameproj.zip

    its ugly but its how i'm trying to get the tilt to work.. perhaps someone can see a better way so when tilting left or right the balls continue to drift downward.
    Oh.... You are so close! Here is what to do.

    In the 'Tilter' prototype -- turn off the first two rules. They are not necessary.
    Then place a constrain behavior in the prototype:

    Constrain Attribute: game.Direction To: (vectorToAngle(game.Accelerometer.X,game.Accelerometer.Y)+90)%360

    And that is it! Your water will flow in whatever direction you want it to go by tilting the device.

    Hope that helps!
    RThurman
  • part12studiospart12studios Member Posts: 620
    that's a slick formula! That totally did the trick.. i knew there must be a simpler way to do it.
    i need to better understand constraints.. they are a mystery to me when to use them..

    happy new years!
    Caleb

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    Glad it helped! Happy new year!

    RThurman
  • part12studiospart12studios Member Posts: 620
    edited January 2012
    ok one last help.. back to constraining.. so if i want to allow tilting so far left and right (180 vs 360) what would be the best way to do this? i've made several unsuccessful attempts at how i think it should be done..

    thanks! :)
  • part12studiospart12studios Member Posts: 620
    yea so far it seems like going over 50 is when you start getting into trouble.. at least on my iphone 4s.. i'm sure the number would be lower on older devices..

    so do i use one "constraint attribute" behavior to set a range of like.. 30 degrees.. to 60 degrees? or would i use two constraints for two ranges.. i just can't seem to get a good mix.. i tried changing the 360 to 180 in RThurman's formula but that didn't give the right results either.

    Thanks!
    Caleb
Sign In or Register to comment.