Car rotation help?

i need the truck to rotate up when its going up a hill Flowlab Game Creator - New Game

1 Like

What’s the link? There’s no truck.


Yeah there’s no truck

There is no truck. But try it with Rotation enabled when you do make it.
I saw Pizza did this and it actually worked out surprisingly well for being completely physics based.

hey i re added the truck can you fix it @CodeAlpaca

yeahhh I think Ima let codealpaca do this

I typically prefer to explain things and then have the person who asked the question implement the solution for themselves because you learn more that way, however, it’s kind of hard to explain this. Because I’m using a mostly physics-based solution, it’s a lot more trial and error than a coding solution would be.

I changed the Truck (really a tank) to be a Capsule Shape

I added a Ramp object. Its collision shape is Polygon and idk why it looks weird in the image. The sprite is literally just moving along down 1 pixel. If you know graphing, the rise and run is 1. Make sure it extends into the ground, this is needed because Flowlab doesn’t handle ramps well and this is just one of the tricks a lot of people use.


Just that causes the “truck” to move up the ramp.
However, going down the ramp isn’t as smooth.

Screenshot 2023-09-01 10.40.01 AM

It will pretty much always flip over like this. Problem here is that it’s rotating too much while going down the hill, so how would one fix this? Well the problem is too much rotation, so what if we limit it?

This code prevents the “truck” from flipping over, but there is another problem with it.
The truck keeps wanting to flip itself over, even if I were to set its rotation down to -10, so this causes it to get locked at the maximum angle.

This is the expression “A < (-45)? (-44) : A > 45? 44 : 0”
*(Expression is basically saying 'Is A less than -45? If yes set rotation to -44, if not: Is A Greater Than 45? If yes, set rotation to 44, if not, output 0. And the filter stops 0 from setting the rotation.

Now what’s the solution to this? Not entirely sure, I can’t just lock it at 0 that ruins the original prompt of rotating a car up a hill. And I can’t go from -45 or 45-degree angle straight to 0.

I tried applying a downward force or setting X velocity to 0, but that didn’t work. Setting X velocity to 0 would work, but you need to stop the movement, which would be kind of odd to just suddenly stop. Then again, I guess it can kind of make sense because if the wheels aren’t making enough with the ground, then it doesn’t have enough traction to move.
Maybe a solution to this while making this into a feature is to slightly lower the movement of the truck the more rotation it has.