Driving in Cone Wars: simplifying 3D vehicle physics

Screen Shot 2016-05-12 at 11.42.54

By Hugo Scott-Slade, Technical Director

Another dimension of driving

When we built our 2D prototype for GDC, we knew driving was one of the key elements to the game’s feel. With no characters in the prototype, the personality had to come from the trucks and how each was controlled. The physics for the trucks were bespoke to the game so this meant we had a tremendous amount of control over the vehicle handling.

When we made the decision to take the game to 3D we knew that personality was just as important,but we quickly discovered this wasn’t a simple transition as the prototype was designed and tuned to be played topdown.

Getting started in 3D

Needless to say 3D physics are more complicated than 2D physics. Going 3D opened us up to Unity’s more established physics system. We could now use the built-in WheelColliders to create a real, simulated vehicle – amazing! However, as I’m sure many of you know, WheelColliders are notoriously hard to wrangle and take a long time to tune.

Enter “Edy’s Vehicle Physics”. We found Edy’s on the Unity forums and it seemed to be the answer to our problems. Edy’s is a 3D physics solution that manages the nitty-gritty of the setup and also comes with some great additional features. It got us up and running within a few hours – we were finally driving around our 3D worlds.

Using Edy’s Vehicle Physics wasn’t without it’s quirks, but it was a great introduction to 3D physics for us.

Pros:

  • It was easy to use (sample scene)
  • It had ‘real feeling’ physics
  • Great community and developer support

Cons:

  • Hitting low obstacles like curbs could make the vehicle jump in the air and spin out of control
  • Physics are based on real values. We couldn’t tweak them exactly how we wanted to
  • We had issues when setting up over the network for remote players. The order of instantiation took a lot of time to get the right setup.

It was great to get setup and going quickly. If semi-realistic/GTA-like physics is what you want then this is perfect. Even if you think it’s not for you it does come with full source and documentation. It was helpful for us to learn the rules of the simulating 3D vehicle physics and then learning which rules to break.

Faking everything but the fun

It was clear that a simulation wouldn’t ever get us the result we wanted because what we wanted wasn’t ‘realistic’. A lot of what I could find online about building 3D vehicle physics was all anchored in reality rather than fun. It was then I came across a brilliant video by Space Dust Studios about how they did their vehicles for a karting game (video; Reddit). We often cited the fun and feel of Mario Kart, so this video was a great reference for us.

This was just as big of a step in the right direction for us as the move from 2D to 3D was. We had full control over how it behaved and if something didn’t feel right, we could change it. It was great to have a solid base for custom 3D physics but this wasn’t the right fit for our game.

Driving - First Custom

Pros:

  • Full control over variables, something didn’t feel right? Change it.
  • A much more simplified setup

Cons:

  • It was developed for hover cars and definitely felt that way (not like heavy trucks)
  • There isn’t any support – you’re on your own

Bringing it all together

The next challenge was to bring the best of all the work we’d done together. We looked at other games we enjoyed and how they handle their vehicles and driving. Games like Rocket League, Mario Kart and Twisted Metal were big influences for us. We also looked at our own 2D prototype and collated a list of everything we wanted to be able to do with driving in Cone Wars.

Armed with the knowledge of the desired outcome and what features were needed to achieve  that, we got to work. We were able to create something which ticked all our boxes, we could do all the things we wanted. Some of the things I loved from the 2D prototype were the J-turns and the drifting and boosting. It was great fun to come flying around and corner all guns blazing and boost directly into an enemy player, taking them out and sending the customers flying. Personally it was really rewarding to get that in the 3D game.

Driving - Drifting & Boosting

Takeaways

Getting an idea from your head into a game can be hard. It’s important to reference what works and regularly test it yourself and with others. If you’re building a games as a business it’s important you build something people can enjoy and understand. Additionally time is a finite resource and there are many other fun things you can be working on; if something is a proving to be a challenge take a step back and reflect on your process and your goals.

  • Invest time where you need it
  • See what games you love do and why that works
  • Using content from the Asset Store is a great way to get up to speed and help you pindown the direction you want to go in without a large upfront time-investment
  • To give your game the personality it needs you have to get your hands dirty and knowing what you want to get out of it at the end will give you the best results

 

Don’t forget to join our infrequent mailing list for Cone Wars updates directly to your inbox.