[WIP] GearBlocks - Build working physics based machines and mechanisms [DEMO]

Hey everyone, here’s a game I’ve been developing for many years. I’ve been posting to my own dev blog for a while, but I thought I’d start a thread here. Hopefully some of you will find it interesting, especially what I’ve been doing with physics in Unity. Thanks for reading, and if you get a chance to try the game I’d welcome any feedback!

GearBlocks is an open ended sandbox game for mechanically minded builders.

You can build a car with rack and pinion steering and a working drive-train with a differential gear. Or you could make a run-and-jump parkour course with motorised bouncy platforms, or an unstoppable walking mechanical elephant. The only limit is your imagination…and physics.

Create
Build or repair your creations anywhere on the map. Snap parts together, resize them, change their materials, paint them, and link their behaviours together. Choose from over 200 parts, including functional mechanical elements such as motors, gears, pulleys, joints, springs, actuators, and much more.

Interact
Turn, grab and shove your machines and watch the parts physically interact. Jump into the driver’s seat and put your vehicles through their paces. Crash and smash your constructions to smithereens.

Improve
Learn how to build with the in-game tutorial scenario. Explore the example constructions to see how they’re put together. Test your builds in the included challenge scenarios.

Customise
Make rag-dolls from body parts and use them as your custom player character. Mod the game with Lua scripting to create your own custom tools, scenarios, challenges and mini-games.

Share
Share your creations with the community, try out what others have made, and maybe learn a new building trick or two along the way!

Out now in Early Access

The game is now available in Early Access on the GearBlocks Steam store page.

More info

GearBlocks Discord

GearBlocks on IndieDB

Other links:-

10 Likes

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.

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 save game system. 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.

Build 0.1.5567 for Windows

1 Like

HOLY CRAP NICE!!!

i think creativity games like this is the way to go… like minecraft, this is seriously amazing!! nice!

1 Like

Thanks Zeblote, the save file was very useful! By disabling a bunch of colliders, I managed to stop it going crazy long enough to see that some of the hinge joints have got messed up as you can see here.

I’ve seen this happen before where joints sometimes drift out of position during construction, as parts get added or removed, haven’t got to the bottom of why this is happening yet though.

This is probably what caused your construction to fly off in the first place, although I’m not sure how part of it went missing, that’s concerning! :frowning:

As for the inventory images getting screwed up, that happens when the render targets are lost. This usually happens during a resolution change, which I account for, but is obviously happening in other cases too.

Sorry your first experience was frustrating, but your feedback was very helpful, thanks! :slight_smile:

Unity 5 physics issues

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!

Not to minimize the problems in any way - but your game is truly an actual working testbed for the new physics in Unity5.

I hope solid solutions to the issues you have materialize soon.

1 Like

New demo 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). Thanks again Zeblote for the save file, that helped me track this bug down!
  • Improved behaviour when exiting a seat, to prevent the player from colliding with the construction.
  • Also added new 3x3 plate, slider x3 and slider x5 parts.

Build 0.1.5581 for Windows

Stunt plane

Over the weekend I 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. :slight_smile:

2 Likes

Instead of adding lots of beams and plates, why not generate them dynamically and let the player chose how long/wide he wants them to be? Easy to use resize tool after placing a beam would be pretty awesome. :smile:

1 Like

Yeah, I had toyed with this idea before. The trick is to come up with a simple interface for the player to choose / adjust the block dimensions, should be possible though!

How about something like this?

You’d activate the tool by looking at a part and pressing shift+s (or maye you can come up with a better way)

Dragging the balls would show a grid and start re-sizing the part in place. There should be almost no restrictions in place so you can make 1x1 plates/beams or useless 100x100 plates.

Changes would only be applied once you actually release the ball, as you might accidently shorten the beam too far and delete a few joints otherwise that aren’t easily fixed.

The build menu would only need a few entries then, a beam and a plate of every material that has a default length of 5 or so.

Nice, yeah I think that could work well Zeblote! I’ll put something in my plan to try this idea out soon…

Unity 4.6 UI upgrade

Hey everyone, apologies for the lack of GearBlocks updates recently. I’ve been working on porting all of the menus and other UI over to the new UI system that was introduced in Unity 4.6. I wanted to get the port out the way sooner rather than later, before I add any new features that require UI changes or additions. Unfortunately it’s taken me much longer than expected, I’m getting there, but I probably still have one more week left to go on it.

Previously I was using the old immediate mode UI system, which has its well known limitations that I won’t go into here, I’m guessing it will eventually be phased out in future releases of Unity. The new system is for sure a lot more powerful and flexible, and of course you get to properly lay out your UIs in a WYSIWYG fashion.

Issues with the new UI system

Unfortunately once I got into it, I found there were some downsides to moving to the new system. For instance, some of the features of the immediate mode UI I was using (e.g. selection grids) do not come “built in” and I had to write additional code to replicate them. Also, some bits of the UI that I populate at run-time (e.g. the parts list in the inventory screen) required significant rework to the code that does the populating (simply because of the totally different philosophies of the old vs. new UI system). The most troubling issue though was the performance of the new UI system, I discovered if you’re not careful you can easily add many ms. to your frame time, with spikes in the hundreds of ms!

UI performance problems

GearBlocks has many separate UI screens that the user can transition between. The “standard” way to implement this in the new UI system (at least from the tutorials I’ve seen) is to use an animation controller to blend each screen between an open and closed state, these states setting the screen’s CanvasGroup visibility and interactibility. However I found that the animation blend added a couple of ms. (from Animator.Update and Canvas.BuildBatch) during a transition. Even worse, despite all screens (apart from the currently active one) being invisible and non-interactible), they still all seemed to get processed and I found that this resulted in several ms. of overhead from the EventSystem update.

To get around the transition blend cost, I did away with animations for the in-game UI and just did the transitions directly from code (I kept using animations in the main menu though as the performance cost isn’t so critical there). For the second problem, I wanted to eliminate any cost for a non-active screen - it’s not really practical to go through and disable each and every UI behaviour, so I tried deactivating the screen’s root GameObject. Unfortunately, while this does eliminate the continuous frame-by-frame cost, it can result in huge performance spikes when activating / deactivating the GameObject (I found hundreds of ms. if you have a complex screen with ScrollRects), so it’s not a viable option.

Luckily I found another solution, which is to have a separate Canvas and GraphicRaycaster for each and every screen, then enable / disable these to transition between screens. This way you get the best of both worlds, no cost for inactive screens, and no cost to activate / deactivate them. I get the impression this is a common trick people use to get around this problem. It seems like there are a few performance tricks people are discovering (such as disabling Canvas “pixel perfect” when using ScrollRects).

Well, hopefully I’ll be done with the UI port soon, and then I can get back to adding new stuff to the game!

This is one of the few instances where I’ve seen the new UI causing more problems than it solved. Though I haven’t witnessed another UI conversion with the same amount of work you’ve already implemented.
Nice to see your progressing.

1 Like

I experience some of the same issues on one of my projects with the new UI also- I had to complete redo everything differently sadly, I hope you find a more elegant solution. The game itself though has an absolutely stunning premise, definitely steam-worthy :slight_smile:

1 Like

UI upgrade complete

It took way longer than I was hoping, but finally I’ve completed the re-implementation of all the menus and screens using the new Unity UI system! This will hopefully pay dividends down the line by making it easier to add new features that require UI.

Build 0.1.5605 for Windows

Full game features

Over the past couple of weeks I’ve been working on some new features: the challenge game mode and construction damage. These won’t be in the demo (got to hold some things back for the full game!) but I thought I’d talk about them so you know what I’ve been working on.

Right now the challenge mode just consists of built in saved games that you can choose from as starting scenarios. The plan is to extend this to add various possible constraints (e.g. a limited part budget) and scoring / win criteria. Eventually there will be a system where you earn points by completing challenges to unlock later, more advanced challenges. There’s still a long way to go on this feature!

I’ve also been working on my first attempt at a damage system. Each attachment starts with an initial “integrity” level based on the material strength of the two parts it joins. When a construction sustains impact, damage is propagated to its attachments, reducing their integrity level. Once an attachment’s integrity reaches zero it is deleted, causing parts of the construction to break off. Note that the parts themselves don’t get damaged or destroyed, only attachments; I decided to do it this way for simplicity.

UI improvements and bug fixes

There are still plenty of new things in the demo though, I have made some UI improvements (animated loading screen, saved game images, and other tweaks), plus a bunch of bug fixes. I’ll keep continuing to update the demo, wherever I improve or bug fix an existing feature. I’ll still be adding one or two new parts to the demo as well!

Build 0.1.5623 for Windows

Spring dampers

The latest GearBlocks demo build now has coil-over spring dampers that can be used to build all kinds of suspension for your vehicles! The spring rate and damping can be adjusted through the part behaviour menu (accessed in the usual way, hover over and hold Shift + E).

I had the physics side working nicely early on, but it took a while to figure out the best way to present the spring / damper functionality to the player, within the constraints of my construction system. In the end I decided to have two parts, a “barrel” and a “piston” that the player fits together to form the spring damper unit. Originally I was hoping to provide a pre-assembled unit to avoid making the player do this, but it would have required too many changes to the construction system to allow for “multi-element” parts. Anyway, this way allows the barrel and piston to be attached in different orientations which is a bonus.

Now, actually using the spring dampers for something useful (like car suspension) might not be immediately obvious, so I’ll make a video soon to go over this.

Ball and Socket joints, CV joints

I have also just finished working on adding a whole new set of connecting joints to the game. There are ball and socket connectors that snap together and can attach to axles or blocks. They allow the connected parts to rotate through all three axes, and are essential for building a proper steering mechanism with a vehicle that has suspension, but they have many other uses too.

I’ve also added constant velocity joints, which attach axles together and allow rotational drive to be transmitted through changing angles. These are useful for building drive shafts for vehicles with suspension, and / or front wheel drive (or four wheel drive).

These parts are not available in the demo, as I’m keeping them back for the full game. I’ll be doing a video on these too though, to show how they can be used, it can get pretty complex!

Build 0.2.5649 for Windows

A new GearBlocks dev diary demoing the spring damper parts.

2 Likes

Come on, where are the resizing blocks! :slight_smile:

Pretty darn cool, seems a bit garry’s mod inspered ?
Keep up the amazing work.