ProjectCastle How I got so many physics. Files for free.

Published August 15, 2017
Advertisement

So just got online when I noticed a few emails asking me how I got so many physic objects working in Unity.

The answer to that is nothing special. On average there should only be a 1000 physics objects on screen. The physics is also a lot more strict on making objects sleep.

The way this is done is the same most AAA games work with art. In a AAA game it isn't rare to have a static duplicate of a skinned mesh. As a example take the players gun, often the gun will be a skinned mesh, playing it's firing animation while the player presses fire.

However skinned meshes have an extra cost just to be in a game, so because exporting the static model only takes a click of a button and the code for swapping them is very fast you can just change your animated model into a static model. Some engines even turns a animated into a static when it's done with the animation.

 

So in Project Castle I did what most games would do with a destructible wall. First I made a object using physic blocks, then I took there meshes and generated a new mesh. The blocks are disabled and the new mesh is displayed. When any object that can hit it is near the static mesh is swapped for the rigid bodies.

 

Now at this point of the blog I thought I would share the code, although @Avalander says my new build still doesn't working so I realized I could just upload the Unity pack. Everything, except Unity, was made by me for this game so you can use it as is.

Import the Unity pack as a custom pack. The layer for shooting is "Water" because the Unity pack doesn't export layers. Space key will swap physics for static meshes, causes a kind of freeze time effect.

 

I would like criticism on my code if anyone has time for it.

 

ProjectCastleFiles.unitypackage

Previous Entry ProjectCastle LastDay.
1 likes 1 comments

Comments

Avalander

Now I could finally play it! It looks cool, I really like what you've done with the buildings falling apart. It's a pity that you couldn't add the aliens, it would have been such a great game!

Unfortunately, I can't provide feedback on the code, I don't have much experience with Unity nor C#.

August 15, 2017 02:01 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement