You're driving me up the wall!

Or at least, not yet you aren’t, vehicle.

Here’s what I am trying to tackle, and I’ve searched and read various posts on this subject, but none exactly apply directly to what I am trying to do:

I am trying to make a vehicle be able to drive up a building (using a ramp), and have it stick to the building the entire time it’s going upwards (if you let go of the accelerator, the vehicle falls off and realigns with the “ground plane”).

I’m thinking I could rotate the entire city, but that seems like it’s going to cause a lot of physics problems with the rest of the props/people/cars. Is there an easy solution that I am missing?

Any help would be greatly appreciated, and I’ll gladly put you in the credits of my game. :slight_smile:

That sounds like a pretty neat game.

The only way I know to muck with gravity is for all objects, and is done by changing the gravity parameter in Edit > Project settings > Physics.

I’d say you’d probably not want to do that, and instead deal with your car individually. So I’d guess you’d have to write a piece of code to apply gravity to your car, with variable direction depending on the game circumstances.

Thanks :wink:

Yeah, I was definitely thinking that, or possible rely on the friction of the wheels to sorta “stick” the vehicle for me. I don’t want my vehicle to ever flip over, so maybe that will take care of it for me?

Sticky wheels might work, but I’d worry about all the problems that would cause. I think just changing gravity for the car might be easier.

As far as not flipping over, it’d be most simple to just run a small no-flip script, where car x z rotations were not allowed beyond, say, 90 degrees.

Perhaps you could apply a downward force (relative to the car) that is proportional to the speed/throttle, when it detects the wheels are on a vertical surface. I don’t know how lifelike PhysX is, but in reality a sufficient force would combine with friction to overcome gravity.

This would also lead to more believable behaviour than ‘breaking’ the physics I think (downforce is a real-world phenomenon, although not this exaggerated of course!)

I think I’d try disabling the gravity on the car, then adding a negative constant relativeForce. You’d have to change the car’s rotation with a ramp or something like that.

This is indeed the key. If your engine generates enough forward force to outweigh gravity, a downward force is all you need. Of course, the car will go slower up the wall than it will move on flat land, but that may actually be desirable. If it isn’t, then gravity should be reduced/disabled when the car is on a steep surface. Note that with gravity completely disabled, your car won’t come crashing down once it stands still, but will just stick to the building (which doesn’t seem to be what you want).