Tilt to move?

SkyMapleSkyMaple Member Posts: 817
edited November -1 in Working with GS (Mac)
how do you make an actor roll around the screen while you tilt the device? Kinda like the game labyrinth with the marble.

btw- I've did this before but forgot the 'code', thanks!

Comments

  • SkyMapleSkyMaple Member Posts: 817
    thats not quite it, it was simpler than that.
  • SkyMapleSkyMaple Member Posts: 817
    right now i have-

    accelerate
    Direction: vectortoangle(-(game.Accelerometer.Y), game. Accelerometer.X)
    Acceleration: 700

    It rolls the way I want it to go but how can I make it slow down when the device levels out, and speed up when the device its tilted dramatically?
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    Try upping the Drag and then also setup a rule that is when accelerometer y is less than a value constrain self.linearvelocity.y to (self.linearvelocity.y*0.9)

    Do the same for the x values too.

    That should cause it to slow down.
  • SkyMapleSkyMaple Member Posts: 817
    nope, that added to my previous accelerate behavior doesn't work right. For the value I used 0.2.
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    ccelerometer controls for portrait would be like this:

    When attribute device accelerometer x >0.5 move right

    When attribute device accelerometer x < -0.5 move left

    When attribute device accelerometer y >0.5 move up

    When attribute device accelerometer y < -0.5 move down

    for landscape switch the x and y's
  • SkyMapleSkyMaple Member Posts: 817
    what do you mean by "move right"? Accelerate, change velocity,move?
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    accelerate or move whichever you want
  • SkyMapleSkyMaple Member Posts: 817
    hmm, thats not working right either...
  • SkyMapleSkyMaple Member Posts: 817
    I need the physics set up exactly like a marble would react inside a box.
  • morphinegamingmachinemorphinegamingmachine Member, PRO Posts: 449
    to make it move at a speed relative to how much tilt make the rule
    move right is accelerometer is greater then .1
    then the move speed can be . game.accelerometer*1500
    thats like .1*1500 for the least speed and .99*1500 for the high speed when its totally tilted

    idk if the gurus agree but thats what i did
  • SkyMapleSkyMaple Member Posts: 817
    morphinegamingmachine said:
    to make it move at a speed relative to how much tilt make the rule
    move right is accelerometer is greater then .1
    then the move speed can be . game.accelerometer*1500
    thats like .1*1500 for the least speed and .99*1500 for the high speed when its totally tilted

    idk if the gurus agree but thats what i did

    but then it wouldnt be smooth, right?
  • morphinegamingmachinemorphinegamingmachine Member, PRO Posts: 449
    i disagree lol, its pretty smooth, the accelerometer is very precise, and if u want more precise movement then that make the activation rule= greater then .01 to move, and speed for movement = game.accelerometer*500
    that way u start moving at a very small tilt, and go pretty slow at the beginning, but u have to tilt aWHOLElot to make it go fast
    when moving left u have to do game.accelerometer*-500
    because the accelerometer value will be negative and u need a positive movement speed at 180 degrees
  • morphinegamingmachinemorphinegamingmachine Member, PRO Posts: 449
    hope it works for you
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    Ok i see what you want, smooth as possible. Here ya go

    Constrain self position x to : self.position.x-(game.accelerometer.y*17)
    Constrain self position y to: self.position.y+((min(.5,max(-5,(game.accelerometer.x+0))))*17

    Thats landscape, figrued thats how you set it up. try that and let me know how it is
  • SkyMapleSkyMaple Member Posts: 817
    I'll have to try this, my computer is updating so it might take a while... I will let you know with in the hour.

    Btw john- congrats on sous chief, you deserve it!
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    thanks man :)

    Yeah try it out and let me know how it is. Should be good.
  • SkyMapleSkyMaple Member Posts: 817
    @johan. Works great! ...until I add obsticals... I added another ball actor to the scene and tested it, the balls don't collide and bounce off of each other nor do they bounce off the walls. This is an obvious problem with the constrain behavior, but how can I get around that?

    Thanks!
  • SkyMapleSkyMaple Member Posts: 817
    morphinegamingmachine said:
    i disagree lol, its pretty smooth, the accelerometer is very precise, and if u want more precise movement then that make the activation rule= greater then .01 to move, and speed for movement = game.accelerometer*500
    that way u start moving at a very small tilt, and go pretty slow at the beginning, but u have to tilt aWHOLElot to make it go fast
    when moving left u have to do game.accelerometer*-500
    because the accelerometer value will be negative and u need a positive movement speed at 180 degrees

    I haven't tried this yet, but do you think you can tell me exactly what I need to use? I don't really understand... :)
  • morphinegamingmachinemorphinegamingmachine Member, PRO Posts: 449
    SKY MAPLE
    listen to the noob! :) if you just use the move attribute and make the speed accelerometer*(what ever number you want) it will bounce! promise! Because bouncing will still change the speed and it scales to how much tilt. idk why it would be less stable? john can u point out why it would be unstable? im jw
    and im admitting that im a noob, so i really want some knowlage dumped on what im doing wrong :) thanks
Sign In or Register to comment.