Orbit speed based on the degree of device tilt...

Ok, so what I want to know is this. If I have three actors orbiting around a centeral point using this formula:

constrain attribute:game.rotate to: vectorToAngle(- game.Accelerometer.X ,- game.Accelerometer.Y )

When attribute game.rotate > 10
Every 0.05 seconds
change attribute: game.counter to: game.counter+0.05

When attribute game.rotate < -10
Every 0.05 seconds
change attribute: game.counter to: game.counter-0.05

constrain attribute:self.position.x to:100sin( game.counter * self.speed %360-120)+ game.planet x
constrain attribute:self.position.y to:100
cos( game.counter * self.speed %360-120)+ game.planet y

... then how do I get the speed of the orbit to be controlled by the amount of tilting of the device?

Thanks, guys :)

Comments

  • SocksSocks London, UK.Member Posts: 12,822
    edited July 2014

    Constrain attribute:self.position.x to:100 *sin( game.counter * self.speed %360-120)+ game.planet x
    Constrain attribute:self.position.y to:100 *cos( game.counter * self.speed %360-120)+ game.planet y

    You don't need the '%360' part . . . so . . .

    Constrain attribute: self.position.x to:100 *sin((game.counter * self.speed)-120)+ game.planet x
    Constrain attribute: self.position.y to:100 *cos((game.counter * self.speed)-120)+ game.planet y

    @gamestudent said:
    ... then how do I get the speed of the orbit to be controlled by the amount of tilting of the device?

    Constrain attribute: self.position.x to:100 *sin((game.counter * the amount of tilting of the device)-120)+ game.planet x
    Constrain attribute: self.position.y to:100 *cos((game.counter * the amount of tilting of the device)-120)+ game.planet y

    To make life easier you should use cosine for x and sine for y, so . . . .

    Constrain attribute: self.position.x to:100 * cos ((game.counter *the amount of tilting of the device)-120)+ game.planet x
    Constrain attribute: self.position.y to:100 * sin ((game.counter *the amount of tilting of the device)-120)+ game.planet y

    . . . but that might change your offset value (-120), so you might need to adjust that.

  • gamestudentgamestudent Member Posts: 504

    That sort of worked, but What I would like; if it's possible, is to have the motion be continuous, like a ferris wheel, and in both directions.

    Thanks

  • SocksSocks London, UK.Member Posts: 12,822
    edited July 2014

    @gamestudent said:
    What I would like; if it's possible, is to have the motion be continuous

    So . . . you want the orbit speed to be 'controlled by the amount of tilting of the device' - and you want this motion to be continuous . . . ? If that's the case then you would need to tell the player to hold his device at one angle - and to keep it at that angle, doing this will control the orbit speed by the tilt amount and keep the motion continuous.

    @gamestudent said:
    and in both directions.

    So . . . you want the orbit speed to be 'controlled by the amount of tilting of the device' - and you want this motion to be continuous . . . and to go in both directions . . . . in that case you would need to tell the player to hold his device at one angle - and to keep it at that angle, and to hold up a mirror to the devices screen so he can see the motion turning in both directions. ;)

  • gamestudentgamestudent Member Posts: 504

    Thanks :\

Sign In or Register to comment.