Collisions, Physics & Surface Types
Physics hull from render basically generates a hull mesh for your model from the geometry of the rendered mesh. It usually isn't the best but it is fairly okay for quickly testing things. To add this to your model, simply look for PhysicsHullFromRender on the type browser and simply add it.
If your model contains bones, it will ask you to pick the bone to generate the hull mesh for. For jointed objects note that you should refrain from using automatically generated phys models and go for physics shaped objects like capsules, spheres and boxes. If it is a biped ragdoll note that you can go for either creating a biped ragdoll or creating just ragdoll parts individually.
Another way to add physics to your model is using a prebuilt physics model which you made yourself outside of ModelDoc. This is usually the preferred way to go for porting old assets since you can re-use your old physmodel. To add something like that simply add the following option:
This option is going to prompt you to load the model file which you'd like to use as a physics model for your model, once it's added simply compile it and toy around with your model which now has some nice physics.
For props with more complex collisions or "concave" type collision please navigate below to Complex Collision Shape
So this is only used in special cases, since this type physics file type is only used for collisions, meaning it will not be able to be moved once its created and it will not fall or react to gravity and so on, think of it like the collisions when you make a map in hammer. It works exactly like that.
so in a case unless you making a gamemode which uses custom terrain which is created and loaded on the fly via code or something, this will not be a common one you will use.
Let's say you wanted a more complex physics shape rather than a shrink wrap, then you will have to use multiple PhysicsHullFiles to build the complex shape.
For example, you want to be able to stand inside of this "box":
Then we need to split the collision into a bunch of individual convex meshes. Here is an example of what it would look like:
At this point you have a couple of options for importing these convex meshes:
- You can save them all into their own model files and proceed to add PhysicsHullFile for every part of the mesh. You will now have a PhysicsShapeList with multiple PhysicsHullFiles within it.
You can click through them to check individually or click the PhysicsShapeList to see the final collision model.
Now in-game you can get inside of this box, unlike the ones PhysicsHullFromRender makes. Of course, it will also let the model have gravity and collisions too.
- Alternatively, you can join all of the individual convex meshes into a model file and then add it as a single PhysicsHullFile with the "Hull Per Element" import mode. This is akin to the traditional way of defining collision models in Source with just a single file for your physics model.
The benefits of doing this is that you can keep the amount of PhysicsHullFiles to a minimum and also keep your directory tidy, but the drawback is that you will need to decide on a single parent bone for your entire assortment of joined convex meshes.
Surface Property and Optimization Algorithm, among these grouped convex meshes, will also be shared, and so it is important that you consider the applications of your collision model and group your hull pieces accordingly when using this method. Here is an example of how this can be done for a wind turbine prop with just two groups and a revolute joint in-between:
What surface does your object have? Wood? Metal? Surface Properties will determine the sound it produces and, if any, decals and particles coming off when you hit it, as well as the automatcally calculated mass.
To change it, go into your PhysicsHull / PhysicsHulls and find this option:
Set it to whatever you want on your mesh. If you have multiple meshes change their Surface Property too. Done!
You may see something like this on your PhysicsHulls, don't worry if that isn't right.
Go to the +Add, search for PhysicsBodyMarkup and add it.
It will ask you to choose a Target Body, you should just have one if you are making a basic model, so just click the one you see. You will see these options, the only one you gotta care about right now is Mass Override.
Put an appropriate number in there in KGs and you're good to go.
When you only have a Sphere or Pillshaped PhysicsShape your Model will roll forever, to change that edit either Angular Dampening or Linear Dampening to your liking.