top of page
  • Writer's pictureDan

SOB: post 5 - Rubbish progress

In the last post you might have noticed a humble black rubbish bin has been added to the street corner...

Physically modelled scenary The bin is an example of street furniture that can be interacted with in the game-play.

The idea for the bin is that the player will be able to drop litter (or other objects) in it and receive feedback/points depending on what they put in the bin. Since the bin is an example of street furniture that is movable, the player should also be able to knock the bin over or throw the bin or hit and kick the bin etc. The Unity physics engine should take care of what happens .. such as the inner bin and litter falling out.

The intent is that all such items are physically modelled with collider and rigidbody components in Unity so that the player can also throw or kick or move any item that falls out of the bin! - Or perhaps kick the bin into the road where a passing vehicle might collide with it etc.

The bin in the previous post was a single object that I created in SketchUp and imported. However, SketchUp does not handle uv unwrapping and it's texturing is therefore very limited. So I started over again and made a new bin model using Blender. This allowed me to uv unwrap it and add photo textures of an actual Belfast bin to it. Here it is...

New multi-object model of a street bin open in Blender

Being new to working with Blender it took me quite a long time to get the hang of the workflow and all the keyboard shortcuts. I scrapped several attempts and in the end settled for a model where the door, walls, top, base and inner bin were all modelled as separate objects so that during game-play in Unity the potential is there to allow the bin to be broken into those separate pieces. For example perhaps a player might bash the bin with a baseball bat until it falls apart? - or perhaps the bin gets pushed in to the road and hit by a cat? In Unity I can connect the individual objects that make up the bin with 'fixed' joints that break when a given force is applied. Unity also allows me to create a 'hinge' joint between the door and the main bin body.

Player stuck in the bin - collider problems and the solution

Here’s a video of the new bin model in game-play ...

I had several difficulties with setting the bin up to work with Unity's physics engine.

1) the bin kept exploding every time I started the game!! It turned out that this was due to the fact that i had created a boxcollider for the inner bin (galvanised silver coloured thing) and a boxcollider for the outer black bin and door and put one within the other. Unity's physics engine does not allow colliders to be inside each other (colliding!) and attempts to rectify it by spitting them apart - causing the explosion!

2) swapping boxcolliders for mesh colliders was also problematic because the bin walls are only 3 mm thick and therefore fast moving items often move further than 3mm between consecutive calculations by Unity (consecutive frames) resulting in Unity failing to detect collisions when a player walks in to the bin. This had comical effect because players could get stuck inside the bin simply by walking into/thru it.

3) Unity does not support colliders with cavities in them ("concave" colliders, or "non-convex" colliders) if they also have a rigidbody - i.e. make use of the physics engine for gravity etc.

So to overcome the exploding bin problem, the solution was to create multiple boxcolliders for the outer bin and also for the inner bin. So the inner bin was constructed with 5 boxcolliders - four walls and a floor. The outer bin was constructed with 5 boxcolliders - three walls and a floor and a top. The outer bin door was constructed with a single boxcollider. These boxcolliders were made 20mm thick instead of the actual mesh thickness of the bin's walls in the models - 3mm. This ensured that the problems of 1 and 2 and 3 were overcome. The bin with all its boxcolliders, rigidbodies and hinge component were then all saved as a prefab.

Incorrect momentum

One further observation is that when a player walks or runs into the bin that it seems to get knocked over disproportionately easily - i.e. does not reflect the momentum of the player or bin. I've set the mass correctly for both player and bin. I suspect the issue is due to the fact that I am moving the player objects by a displacement rather than by applying a force! This should really be addressed now before it becomes a bigger problem. Something for me to look into in the next post perhaps!..

19 views0 comments

Recent Posts

See All


bottom of page