Jump to content
  • Advertisement
Sign in to follow this  
  • entries
    6
  • comments
    15
  • views
    738

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

Sign in to follow this  

789 views

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

Sign in to follow this  


1 Comment


Recommended Comments

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#.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!