How do I use physics to make a (top down) car move up a hill?

0 favourites
  • 4 posts
From the Asset Store
Complete game or template for a hill climb racing model.
  • I'm working on a simple (for fun) physics game that I'm hoping I can knock out in a week or so. Unfortunately, I'm struggling a little with the physics. Could someone maybe give me some tips to get me started?

    What I need:

    I plan to have a vertical scrolling topdown screen. It will look like a road and I have some ideas to help me *suggest* that there is a flat part, and then a fairly steep ICY hill. The goal of the game is to drive as high up the hill as you can.

    UP ARROW = accelerate

    LEFT ARROW = turn left

    RIGHT ARROW = turn right

    As the car moves up the hill I'd like for it to get harder and harder to control, turning slightly right and left as the tires slip on the ice.

    Eventually, the car should stop, due to gravity. (And I might even have it slide back down the hill.)

    HOW?

    To simulate the hill should I increase the world gravity every 0.0x seconds? Or should I use one of the other physics properties?

    For the car I'm currently applying a vertical force (270 degrees??) to "drive" the car forward. I may randomly introduce rotational force that players will need to counteract with the controls.

    Am I approaching this the right way?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Since it's topdown, I'd never use physics in a setting like this.

    Probably the best solution is just making a treadmill, where objects are moved from top to bottom, and the car stays in the middle. The apparent car speed is actually how fast parts travel the screen.

    Objects that go outside boudaries can be reused sending them to the top, or just destroy the bottoms and create new top parts to descend.

    To simulate the roughness of the terrain, personally I'd just add details to the art that suggest it, and make the terrain move slower to the bottom.

    If you like the physics for the visual appearance of the movements, I'd suggest combining my first suggestion with the Tween behavior to simulate the possible "skid" effects you'd get on physics.

  • Thanks for the reply!

    I actually need the physics because I've decided I want my car to slide down the icy hill, hitting other cars, trees, etc. I'll need the physics for that.

    Perhaps I could turn physics off for the trip up the hill, and then turn it on for the slide down? (If that's not possible, then maybe I could use one car to drive up the hill, and at the top I'll switch it out with a physics version of the car, and let it pinball down.)

    Would that work?

  • Ok, your point is valid for when the car goes crashing down, and it makes me think that, yes, you are approaching it the right way then.

    But considering this approach, the car is in fact moving up the layout, so instead of setting a timer to adjust the gravity intensity, I would be more inclined (lol) to use the player's Y position as a reference point for it.

    For the rest, it seems pretty interesting, I'd actually be stoked to see what you come up with.

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