How do I create a sprite that moves by tilt with momentum

0 favourites
  • 2 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • Hey all. I'm messing around with C2 and I want to try a create a game like Velocispider.

    Subscribe to Construct videos now

    Something you don't see in the trailer is if you hold you phone at an extreme left or right tilt, the player character will gain speed/momentum and hit the screen edge really quickly. Basically, you holding the phone at almost an upside angle will make the character "fall" left or right very fast. I'm not sure how to create that sense of momentum/acceleration/physics/gravity when tilting. Here's the basic code I've got so far. Should I use some sort of physics on the player? Thought cchanging the speed or acceleration of the sprite with a steeper gamma number but that didn't work as expected.

    Thanks for looking and Merry Christmas!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You can use something like this:

    Set platform speed to abs(Touch.Gamma)*10

    Or with clamp to limit minimum and maximum speed:

    Set platform speed to clamp(abs(Touch.Gamma)*10, 100, 1000)

    The more the phone is tilted, the higher the speed will be.

    You can use a similar formula for acceleration.

    Of course you'll have to experiment a lot to get these numbers right.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)