How to use the accelerometer

Sheldon392Sheldon392 Member Posts: 43
edited November -1 in Working with GS (Mac)
I'm making a snowboard game were you move left and right and rotate either clock wise or counter. I need to now which accelerometers are what rotation and and how to implement them into my game.

Comments

  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    try this

    constrain self rotation to: vectorToAngle(device.accelerometer.y, device.accelerometer.x*1)
  • Sheldon392Sheldon392 Member Posts: 43
    apply this on the snow board actor???
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    yep
  • Sheldon392Sheldon392 Member Posts: 43
    and then it will work from there is there anything else to do
  • Sheldon392Sheldon392 Member Posts: 43
    is that all in one constrain or two constrain attributes
  • Sheldon392Sheldon392 Member Posts: 43
    Ok i have used the code ----- constrain attribute: self.rotation to vectorToAngle(devices.accelerometer.y,devices.accelerometer.x*1) -------- it works great accept the snowboarder comes sideways and when he lands on a platform he stays in the same rotation position, I want him to level out with the platform he lands on.
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    merged your 2 threads.

    Not sure im getting what you asking. Youu mean u want him to rotate to the same angle parallel with the ground when he lands?
  • Sheldon392Sheldon392 Member Posts: 43
    yes so if he lands on a 30 degree slope i want him to turn 30 degrees
  • Sheldon392Sheldon392 Member Posts: 43
    My actor uses the accelerometer to rotate but when he lands on a for example a 30 degree slope and he was rotated 0 degrees before he lands on the slope and he stays in the 0 degree position after he lands on the slope. i need him to stop rotating to the accelerometer when he is on a slope or platform.
  • old_kipperold_kipper Member Posts: 1,420
    this will have to set up before there is a chance of the actor being to close to rotate to the correct angle for the land so I would have a field done with coordinates or invisible actors that jump him out of the accel based behaviour and revert it back to the standard gravity set at about the actor's size above the surface he is to land on.
  • Sheldon392Sheldon392 Member Posts: 43
    ok thanks
  • Sheldon392Sheldon392 Member Posts: 43
    Ok i changed my mind i want the accelerometer to control the direction the actor moves. there needs to be a neutral position and a left and right position for the actor when you rotate the device.
  • Sheldon392Sheldon392 Member Posts: 43
    can anyone answer my question
Sign In or Register to comment.