Moving an object with Tilt.

swalkerswalker Member Posts: 29
edited May 2012 in Working with GS (Mac)
I know this question has been asked before but I am still struggling, is there a simple (noob friendly) step by step system that I can get an Actor to respond to me tilting the device left, right, back or forward? I just need it to move in response to these movements.

Thanks.

Best Answer

Answers

  • MarkOnTheIronMarkOnTheIron Member Posts: 1,447
    The simplest thing is to use the accelerometer attributes:

    -If device.accelerometer.X is < than -0.05
    --accelerate/move direction 180
    -If device.accelerometer.X is > than 0.05
    --accelerate/move direction 0
    -If device.accelerometer.X is < than -0.05
    --accelerate/move direction 270
    -If device.accelerometer.X is > than 0.05
    --accelerate/move direction 90

    Or something like this. Play with numbers and try for yourself.

  • britto24britto24 Member Posts: 35
    Check out this tutorial:
  • swalkerswalker Member Posts: 29
    thanks @MarkOnTheIron - but - I am so new to this, I am not sure what to do before this bit? Do I create a Rule first? I have tried just dragging in the Change attribute behaviour. Sorry for my frustrating noobishness...
  • britto24britto24 Member Posts: 35
    edited May 2012
    @swalker Yes, create a rule on your Actor first that says When Attribute device.accelerometer.X is < than -0.05 ...then follow the rest of @MarkOnThelron rules. You must create four rules for up, down, left, and right. One rule for each. Hope that helps!

  • swalkerswalker Member Posts: 29
    ok, but i am trying to do this all within an existing scene, which has walls with a restitution of 0.1. Do I need to alter restitution on this actor? How about Movable? etc.
  • swalkerswalker Member Posts: 29
    i try this, but the actor just falls out of the screen - could this be to do with restitution of walls?
  • britto24britto24 Member Posts: 35
    Hmm, I'm not sure. You could try it out by adding another rule under each When Attribute device.accelerometer.X is < than -0.05...etc saying when actor receives key Up is down....etc... like in the video. This will simulate the tilt for you so that you can test the restitution, movable, etc...
  • britto24britto24 Member Posts: 35
    edited May 2012
    i try this, but the actor just falls out of the screen - could this be to do with restitution of walls?
    Oops, didn't see this comment...
  • britto24britto24 Member Posts: 35
    edited May 2012
    @swalker

    Make sure your Actor is colliding with the walls. Add a collide attribute to the Actor (do not create a rule). Also make sure you have walls just outside of the viewable play area so that when your Actor collides with the walls, it stays in screen. You also need to make the walls not movable and check fixed rotation.

    Hope that works for you!
  • swalkerswalker Member Posts: 29
    ok, done this but now the actor just bounces up and down and is unresponsive to the arrow keys (as per instructions in video)..

    many thanks :-)
  • britto24britto24 Member Posts: 35
    edited May 2012
    Hmm, that's gotta be a rule inside the Actor. The Actor needs to be told to slow down if it keeps bouncing up and down. I'm not sure about this one... Sorry I can't think of the answer for this one. Anyone else have an idea?

    Make sure the friction is set to 0 on the Actor and walls...
  • swalkerswalker Member Posts: 29
    Cool, well the friction has stopped the bouncing, but now it is unresponsive to arrow keys (so I guess will be unresponsive to accelerometer when i test on device too).

    anyways, here's the project if you feel like glancing over it and seeing if anything obvious is leaping out: http://www.sendspace.com/file/4k39n3

    thanks tonnes for your help britto! really appreciate this :-)
  • britto24britto24 Member Posts: 35
    edited May 2012
    Cool, well the friction has stopped the bouncing, but now it is unresponsive to arrow keys (so I guess will be unresponsive to accelerometer when i test on device too).
    Hmm, yeah if the arrows don't work the tilt won't.

    Great, I'll take a look at it. I'm still fairly new to GS, but I'll see what I can do. Give me a little bit to get back to you on it. I won't be in front of GS for a while. But, tell me quick what you want it to do exactly...

  • swalkerswalker Member Posts: 29
    wow, thanks again - total life saver.
  • britto24britto24 Member Posts: 35
    Great @MarkOnThelron!

    @swalker Glad @MarkOnThelron could help! Nice ^:)^
Sign In or Register to comment.