Just built this in the game, a plane with working 4 cyl boxer engine, ailerons and rudder. It doesn’t actually fly though because there are no wing lift physics in the game (yet), but it taxis around pretty good. 🙂
Tag: gearblocks
GearBlocks Demo 0.1.5581
New in this build
Over the last week I (hopefully) fixed some of the physics bugs that were a point of frustration for people:-
- Fixed bug where hinge attachments would sometimes drift from their correct orientations, causing incorrect physics behaviour (where the construction would jump about all over the place).
- Improved behaviour when exiting a seat, to prevent the player from colliding with the construction.
- Also added new 3×3 plate, slider x3 and slider x5 parts.
Unity 5 physics update to the update
For some time I’ve been trying to resolve the physics issues after upgrading GearBlocks to Unity 5. I’ve had success with some issues, not so much with others. I’ll sum up where I’ve gotten things to so far.
Rigidbody rotation unfreezing
When unfreezing a rigidbody, its rotations weren’t being unfrozen, this bug happens if you had already modified the rigidbody’s inertia tensor. After submitting a bug report, I heard back from Unity – turns out the workaround is to restore the inertia tensor after unfreezing, which works fine.
Collision contact tolerance
The collision contact tolerance seems to have significantly changed with Unity 5. What I thought was my gear constraints not working properly was actually due to the moving parts (blocks, axles and gears) within a construction colliding with each other, and everything was getting all jammed up. One workaround I tried was to shrink the colliders, trouble is I had to shrink them by quite a large amount and even then I’d still get occasional unwanted collisions. Another option would be to disable collisions altogether between neighbouring parts, but that’s problematic as you might actually want them to collide in certain situations.
Unstable collision behaviour
For some constructions when contacting the ground, their collision response with the ground is kinda jittery and they keep bouncing around for ages after the initial collision. After some experimenting, it seems this behaviour is worse with the small fixed update (i.e. physics update) time step I’m using (5ms vs. the default 20ms). Not much I can do about that though, as I need the smaller time step for accuracy with fast spinning stuff.
Instability at high angular velocities
On the subject of fast spinning stuff, despite the aforementioned small time step (and also a high solver iteration count), gears / axles spinning a high rpm now become unstable and start wobbling around. With the same settings in Unity 4 this was rock solid. I tried playing around with these settings but I couldn’t get it to be stable, more experimentation is required, but this could be a real show stopper.
Hinge joint motors
When switching on a joint motor, there is a bug in Unity 5 that means the connected rigidbodies don’t get woken up, and so they don’t start moving if stationary. The workaround is to explicitly wake up the rigidbodies when turning the motor on. I also found I had to multiply my torque values by a factor of around 50 to get similar behaviour to that in Unity 4.6.
Hinge joint limits
I use angular limits to force a hinge joint to a particular angle by setting the limit min and max values both to that angle, but this stopped working properly in Unity 5. I found the fix was simply to ensure there is a small delta between the min and max.
Configurable joint velocity drives
I still can’t get these to work at all, I submitted a bug report to Unity but haven’t heard back so far. Hopefully they’ll be able to fix this one.
In summary, I’ve got fixes / workarounds in hand for most issues now, but there are still a couple of show stoppers (namely velocity drives and stability at high angular velocities). So for now I’m still sticking with Unity 4.6, I really need to get back to making actual progress on the game!
GearBlocks Demo 0.1.5567
Getting the word out
I’ve now created an Indie DB page for GearBlocks, from now on I’ll be hosting the demo builds there rather than on Dropbox. I’ve also created Greenlight Concepts and Facebook pages for the game.
- http://www.indiedb.com/games/gearblocks
- http://steamcommunity.com/sharedfiles/filedetails/?id=415701438
- https://www.facebook.com/gearblocks
I’ve also been playing around with a logo for the game, which was fun I have to say!

Latest build
In the latest demo build, I’ve enabled the new save game system that I mentioned in a previous post. As well as being able to save your constructions, this also provides a rudimentary way of sharing them with your friends. Saved games are stored as files in the SaveGames directory in the GearBlocksDemo folder (i.e. right next to the executable, you can create it if it doesn’t already exist). You can load up someone else’s saved game by copying their file into this directory.
Unity 5 physics bug update
Over the last week I also had a look at some of the Unity 5 physics bugs I mentioned in an earlier post.
It turns out the rigidbody freezing bug only happens when I modify a rigidbody’s mass properties (i.e. mass, inertia tensor etc.) I was quite easily able to repro this in a very simple project, so I’ll send this off to Unity when I get a chance.
After browsing the Unity forums I found out that hinge joint motors not working is caused by the motor not waking up the rigidbody. As a temporary solution, if you force the rigidbody to wake up every update, the motor works. I also found I had to multiply my torque values by a factor of around 50 to get similar behaviour to that in Unity 4.6.
Velocity drives definitely aren’t working for me. Again, I was able to repro this in a very simple project. One for another bug report.
I haven’t had a chance yet to look at the hinge joint limit and OnCollisionExit issues, but I’ll keep chipping away at these next week. I also noticed that my gears don’t seem to be working properly, sometimes the gears (particularly rack gears) get stuck. I checked and the configurable joints I’m using for the gear constraints do still seem to be updated correctly, so I’m not sure what’s changed here. I always was concerned I’d find some slightly different behaviour in Unity 5 with PhysX 3.3 that would unavoidably break the delicately tuned physics setup in my game, and this may be evidence of that. Let’s hope not, more investigation required!
GearBlocks Demo 0.1.5557
GearBlocks
Well, my as yet unnamed game now has a title – GearBlocks. It was quite hard to think up a name that summed up the game in some way, as well as being short, easy to remember, and not already in use. In the end I had to just pick something and go with it!
Full vs. demo builds
I’ve now set up a simple build pipeline that lets me build demo or full versions of the game. As I add more stuff to the game, this will allow me to easily exclude certain features or content from the demo.
Build versioning
Builds of the game are now versioned, and the version number is shown in the game. This means I can release standalone builds of the game on a regular basis from now on, yay!
Phasing out the web player
https://dl.dropboxusercontent.com/u/157530041/GearBlocksDemo.html
For now the web player build is still available at the link above. I think I’m going to stop bothering with it soon though, and just release the standalone version, as there are starting to be too many difficulties with it:-
- The new save game system doesn’t work due to the .NET serialization problems I mentioned in the last post.
- It seems getting the .NET assembly version isn’t supported due to the web player sand-boxing, and I need this for showing the build version in game.
- For some reason Unity is now always building the web player as a “development build”, even when this build setting is turned off.
Playable build – updated
Save game system overhaul
Over the last week I have completely reworked the save / load system. Previously I was using Unity’s PlayerPrefs to save game state into, which was only ever a temporary solution. The PlayerPrefs are only intended for small amounts of player settings data, not for save games.
Now I serialize everything into a single binary file per save game (into a local “SaveGames” directory). This does away with the old fixed slot based system and allows you to name your save games and have as many of them as you want.
This works great for the standalone build, but the Unity web player doesn’t allow file IO for obvious reasons. So for the web player I tried saving the binary data into PlayerPrefs (much like I used to do with the old save game system). This works fine, however the .NET serialization I’m now using doesn’t seem to work in the web player (deserialization fails with a FieldAccessException for some reason). I don’t have time to look at this right now, so I’ve had to disable save / load in the web player for now.
Unity 5 upgrade on hold for now
This week I tried porting over to Unity 5. It went pretty smoothly to start with, a few shader and code tweaks were required to get everything running properly, but nothing too bad. However once I got things going I found some pretty fundamental physics bugs that totally break my game:-
- Once frozen, rigidbody rotations can’t be unfrozen (positions are fine).
- Joint motors, limits and velocity drives seem to be non-functional (at least when setting them from code).
- The OnCollisionExit callback never seems to be called.
It’s a pity really, as I can already tell the physics performance is significantly improved (which I sorely need!), but for now I’ll have to stick with Unity 4.6. Hopefully Unity will resolve these issues fairly soon.
In the meantime I’ll have to re-jig my task plan a bit, but it shouldn’t hold things up too badly.
