Whammo! |
One of the first things I wanted to try out for this project was a way to design interesting yet realistic handling for the player's car. Obviously, I wanted it to be intuitive and fun for the player, as well as looking "realistic" and cinematic - two things which are often opposed.
The original Quarantine game was no help here, as it actually handles more like a real car. Allegedly, according to Ray Larabie, who worked on the game:
The original demo was done right about the time Wolfenstein 3D came out. There were some flat shaded polygon cars running around the streets but the poly count was limited for forty, Not enough for round wheels.[...] After we switch to sprite cars we were used to the idea of hovercars.So despite having hovercoils instead of wheels, the car would only turn while moving forward or backward. The main difference was if you got hit, you'd pinball around a bit. I wanted to make a genuine "hovery" feel, and felt like that involved drifting, and even strafing, which would make hovercar combat significantly more fun.
There were three things I could see myself experimenting with:
- Physics-based force applied to the four corners of the car, mimicking the actual force that would be generated by the car's hover engines. I knew this would probably give me the most realistic effect, but was worried about the efficiency of using this en masse. More about this later.
- Wheel colliders, with "slippery" wheels. The nice thing about wheel colliders is that it emulates the shocks absorbing the car's shifting weight. I was hoping to basically make wheel colliders, but with invisible wheels, and give them very little friction to allow the car to slide laterally. This didn't work well, as the car still had to be moving for it to register any forces acting on it. I considered a few tank-type setups, using three wheels on a side, which allowed for turning of a dime but not sliding. Additionally, the more I looked at wheel colliders, the more finicky they seemed - there were a lot of variables involved that I didn't really grok. Additionally, I have the impression they wouldn't have been any more efficient than physics forces, ad they themselves use similar (or more) such forces. It's possible someone with a better understanding could have made this work, but it wasn't the right approach for a laymoron such as myself.
- Using an invisible, frictionless collider as a sled, with the car interpolating its rotation as the sled slides over uneven ground. I abandoned this idea without even experimenting because it seemed like it would never have worked for many reasons (if you've done this convincingly, change my mind!)
I've also lowered the rigidbody's centre of gravity, which makes the car more stable and likely to stay upright. This is a bit of a tricky thing because if it's set too low, the car will try and stay level even when on inclined planes, and if it's not centred to the forces applied by the hovercoils, it'll list or flip very easily. I ultimately just added some code to set it to the average positions between the hovercoils.
As I mentioned, I feared this would be a performance problem if every NPC car used this system as well. My hope is that I can fudge NPC movement while they are idly moving about the city streets, only switching to full physics mode when attacked. That's a way off - stay tuned!
It still need some fine tuning to get things where I want them, but I think it's pretty good overall. One thing I'd like to experiment with is making adjustments to the centre of gravity as the car accelerates to accentuate the feeling of the car's weight shifting.
What does everyone think? Feel free to comment and let me know! Next post will probably be about a shader I made for the car. It probably won't be a terrible read!
No comments:
Post a Comment