S&box Wiki

Revision Difference

PhysicsHullFromRender#543893

<cat>Dev.Model</cat> <title>Collisions, Physics & Surface Types</title> # PhysicsHullFromRender 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. ![PhysicsHullFromRender](https://i.imgur.com/ARJRV1t.png) 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. # PhysicsHullFile 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: ![PhysicsHullFile](https://i.imgur.com/GQrUh1Y.png) 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. ⤶ <warning>You can technically use ![PhysicsMeshFile](https://i.imgur.com/ZtAcaUL.png) physicsmeshfile since its almost the same, but i recomend not to it cant calculate mass and has issues with it like it can cause it not to actually do physics on it, just use PhysicsHullFile it does the job, and does it well and has no issues really like physicsmeshfile does</warning>⤶ ⤶ <warning>I advise you not to use ![PhysicsMeshFile](https://i.imgur.com/ZtAcaUL.png) (physicsmeshfile) because it has issues. For example it can't calculate mass and may cause it not to actually do physics to self. Just use PhysicsHullFile - it does the job and does it well, without issues.</warning>⤶ # Complex collision shape Lets 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. So for example, lets say this open "box" you wanted to be able to stand inside of. ![example model](https://i.imgur.com/OBL0kyb.png) well then what we would need to do is split the collision into a bunch of individual convex meshes that are all on the model. here is an example of what it would look like ![multiple collision meshes](https://i.imgur.com/sJLwj08.gif) Once you have done this save them all into their own model files, and proceed to add PhysicsHullFile like mentioned above, but do it over and over for every single collision mesh you made, you will now have a PhysicsShapeList with multiple PhysicsHullFiles within it. ![example of physicsshapelist](https://i.imgur.com/gMjfl4w.png) you can click through the check them all, and then click the PhysicsShapeList to see the final collision model. ![final result](https://i.imgur.com/3J3Vgbc.gif) Now ingame your model with have a collision model you can enter into unlike the ones PhysicsHullFromRender makes, and it will still work ingame with gravity and collisions! # Overriding Models Calculated Mass So you may see something like this on your PhysicsHulls, dont worry if that isnt right. ![Calculated Mass: way to big or small](https://i.imgur.com/uggIM5R.png) Go to the +Add and then search for and add PhysicsBodyMarkup ![physicsbodymarkup](https://i.imgur.com/KZvf9rB.png) It will ask you to chose a Target Body, you should just have one if you are making a basic model, so just click the one you see. Now you will see these options, the only one you gotta care about is Mass Override. ![PhysicsBodyMarkup](https://i.imgur.com/mI7UBXO.png) You can put any number you want in there to change the mass in KG! its mass is now at your command, no worrying needed about calculated mass. # Changing the surface property This meaning what type of surface is your object. Wood? Metal? And so on, these will determine the sound it produces and if any decals or particles come off when you hit it or shoot it. So to change it you have to go into your PhysicsHull / PhysicsHulls, and find this option ![physicshull surface property](https://i.imgur.com/nTykwaD.png) now you can set it to whatever you may want, if you only have 1 physics mesh then done, if you have multiple, go and change them all to the same surface property too! and its all done!