Anybody remember Stunt Playground from back in the day? It was basically a vehicle physics sandbox game written in Ogre with Newton physics, and the author ended up open-sourcing it.

I'm totally new to Godot, and I thought that porting the game over would be a fun way to explore a variety of features in Godot, learn best practices, etc.

I've just gotten started and here's what I've got so far:

  1. Imported track, one vehicle, and three props from Ogre mesh to Blender, re-exported them as gltf2
  2. Manually added collision info from within Godot (but I plan to import the original collision mesh files as well)
  3. Ported vehicle steering and engine/transmission C++ code to GDScript
  4. Set up Godot vehicle with original physics settings for Newton, did a lot of tweaking afterwards
  5. Added a quick 'n dirty handbrake simulation

On deck:

  1. Import the rest of the props and vehicles, with proper collisions
  2. Figure out how to update all the materials for the physically based system, so they're not all blue and shiny
  3. Refactor the vehicle GDScript to share the code among all the vehicles with different engine parameters for each one

Once I get to that point, it should be possible to manually build playable scenes and I'll post the project on Github. After that, I've got sounds, trick scoring, and a vehicle/arena selection screen to add. If I'm super motivated I could look into the replay system and the interactive editor from the original version as well.

Stay tuned for progress reports, and I'll update once I have the source online as well.

I am really interested in seeing how you did the vehicle physics - my project also has cars and physics are something I have grappled with a lot...

@Zireael said: I am really interested in seeing how you did the vehicle physics - my project also has cars and physics are something I have grappled with a lot...

There is definitely a dark art to getting a Bullet vehicle to behave properly, and I'm close but not quite there yet. I might end up doing a couple write-ups based on my vehicle experiences, and maybe also the math behind making a gearbox for your vehicle.

For now though, some progress! I've got the materials set up in Blender now (although it took reading the source code for the gltf2 importer!) and trimesh collisions exported for the static body props as well. This means that I can now import a single .gltf file and treat it as a complete prefab without manually wrapping it in its own scene, adding the collisions, etc.

I've got a couple more props imported as well:

22 days later

Update time! I've got all the props imported along with their collision objects. Importing OGRE .mesh files is straightforward enough once you find the right Blender importer, but the interesting part was I wanted to use the original collision objects as well. They were stored in xml files from "Rigid Body Designer" and also made use of collision primitives such as cones and cylinders that are not natively supported by Godot. I wrote a Blender importer for this file format, and it will also dynamically generate a convex hull for the unsupported primitives and name them appropriately for the Godot importer to turn them into collision objects. Actually, I ran into a limitation using GLTF here as well; the trick to turn Empties from Blender into Godot collision primitives doesn't work (both the fault of the GLTF exporter and the Godot GLTF importer), so I made my cubes convex hulls as well. Not optimal, but it made my workflow really easy:

[Blender] Import .mesh > Import .rb > Add PBR material and apply texture > Export GLTF [Godot] Import GLTF > Rearrange scene tree into rigid body > Save as scene

The cone prop, in Blender and Godot:

! !

Here's a few action shots displaying some of the props in-arena:

! ! ! !

The last part before I put this up is to import the rest of the vehicles, and refactor the vehicle code so it's reusable across all of them. At that point, building your own arena becomes purely a drag-n-drop affair in the designer.

Following that, I still plan to do a 2D GUI to make a title screen for vehicle/arena selection and a HUD with speedometer. I'd like to add sounds as well.

a year later

A year later, and I've decided to pick this project back up! I've done a couple other things in the meantime and with some more experience under my belt now, I'd like to finish this one off properly. Stay tuned for more regular updates...

Feels nice to dive back into this! A few changes since my first effort and I've hit my first milestone: Un-shinied the materials so that PBR doesn't interfere with the originally intended colors Converted the original skybox into a panorama so it could be used * Added support for loading all the original pre-made arenas

I've got the code uploaded here for anyone interested in the vehicle setup: https://github.com/jonri/StuntPlaygroundGodot

This version is currently hard-coded to one arena but you can change which one loads if you find the right place in the gdscript! If you do give the current version a spin, use the arrow keys to drive and R to flip back over when you get stuck.

There's only one car really working right now, it needs more tuning but it's quite playable in its current state. I was impressed with how well the original stacked props held up considering the original used an entirely different physics engine. There's definitely more physics tweaking to be done though, I've seen some intermittent jitter issues.

For my next milestone, I'd like to: Get all the vehicles running Get the camera working the same as the original * Fix the unsmoothed edges on the assets that need it

I'm not surprised the stacked props work well, the Bullet engine is known for having fairly stable physics.

The recreation looks good, now it could use some more variance in the ground (such as different heights, multiple tiers, ect...).

I did some work cleaning up my vehicle logic, and now I have two vehicles that work fairly similarly to the originals. The top speed is within 10% of the original in each gear, and they slide and roll about as much as the original versions did.

Then I moved on to the monster truck, and this happened:

This is with no input at all; no engine force, braking, or steering.

Looking at the actual engine code, the VehicleBody and VehicleWheel have some pretty glaring bugs right now. For instance, choosing which wheels are used to drive doesn't actually do anything (I turned them all off and could still drive). There are a couple instances of documentation that are just plain backwards (a 0.0 - 1.0 scale working the opposite of how it's documented), and the code itself has several TODO items along with older code that the next person who came along didn't understand.

A little bit of this is already addressed with a 3.2 milestone, and I found an attempt to both correct some issues and add new vehicle features in this branch. I need to test this version and see if it addresses any of my issues. At the very least, I'm pretty sure it would help me close the gap on my working vehicles.

On the other hand, I really wanted to keep this project on a stock version of Godot so it remained accessible to more people. Maybe for now I'll skip the monster truck and get the rest working, and see if I can push for some more fixes to go into 3.2.

It could be worse, there have been many versions of Unity and Unreal where vehicles explode or go flying off into space. It appears to be a popular thing in engines accessible to indies :3

Having perfectly working vehicles of all types could actually be a breakthrough for the market.

Using the vehicle fixes branch I mentioned did the trick! It's not perfect and I'd have to re-tune the parameters, but here it is...

The other nice thing is that the forces and steering are per-tire so I could have the steering work like the original as well. Since this is all unofficial right now, I think I'm going to leave the monster truck out and keep going, and in the meantime see what code we can get merged for a future version.

12 days later

I've posted some PRs for bug fixes, and now I'm back to working on vehicles...

I've got a few materials and such to tweak, but they are all driving! I've also got the main vehicle camera working the same as the original now.

5 days later

It's great that your coding abilities help to improve Godot itself as well, depending on the needs of the game. =)

This type of development is what sets Godot apart from the major engines. I know Epic has made Unreal "Open Source" on github, but they've become known for their rather poor perception of community pull requests.

2 months later

Real life has been a little busy lately but I've been squeezing in time to work on things here and there. I got the materials taken care of but still wasn't too happy with the vehicle physics. Between wanting to make some incompatible changes to VehicleBody/VehicleWheel and rumors of those nodes being removed from the engine someday, I ported the engine code for those two nodes into pure GDScript. The most immediate need I have is to improve the wheel collisions, as a single ray for each wheel doesn't do so great on ramps. Secondly, the friction between the tires and the ground can get a bit wonky when you land hard and skid. Anyways, I plan to gradually make those improvements while getting back into other areas too - I'm getting a little burnt out on the vehicle.

If anyone wants to tinker with the GDScript version of the vehicle nodes themselves, I've got it in plugin form here: https://github.com/jonri/godot-raycast-vehicle

I still need to do some code cleanup on this since it was a straight port from C++. After that I'm planning to build my improvements into a separate plugin so the original can maintain compatibility with the engine nodes.

a month later

Really great work of yours! I hope you'll find the time to submit some extensions as PRs into Godot. The engine is seriously lacking in this department. While the official demo is very rudimentary, with your code examples I at least see a path to implementing a proper offroad vehicle.

Looking really good! looking forward to new infos!

Physics based games hold a lot of potential for fun, just because of the physical interactions. So this should build up quite a following (which is already really good!)

Keep it up!

a month later

Thanks everyone for the nice words! I'm still making progress in my free time, so I thought I'd share an update...

First up, I've got code to load in all the cars and let you switch between them when you start. Pretty straightforward in theory, but they aren't the most stable things in the world when you spawn them in and drop them in place. There should be an "optimal" start height where the suspension is at equilibrium for each car, I might have to determine that experimentally and save it per-vehicle.

Next, I've got all the camera angles imported from the original game. I think something is a little off with some angles when I converted from the original coordinate system to Godot's, I've got one bad camera view, and the occasional problem with the camera flying around to the other side when the car tumbles past a certain angle.

Finally, I added in the spark particles that happen when the car hits an object. The collision work I did to get to that point should also pave the way for me to add in sounds, dirt particles, friction on different materials, etc.

That's awesome! Keep up the great work, jonri!