Physics software in game development
Soft body (or soft body dynamics) simulates the movement of deformable objects, changing shapes and other physical characteristics. For example, this can be used to simulate clothes or create more realistic characters.
basic settings
A software node is used for software simulation.
We will create a flexible cube to demonstrate the software settings.
Create a Spatial
new scene rooted at the node. Then, create a Softbody
node. Add CubeMesh
in the mesh
properties of the node in the inspector , and increase the subdivision of the mesh for simulation.
Set the parameters to obtain the desired software type. Try to keep Simulation Precision
(simulation accuracy) above 5, otherwise, the software may collapse.
note
Please be careful with certain parameters, because certain values may cause strange results. For example, if the shape is not completely closed, and you set the pressure to be greater than 0, the soft body will fly around like a plastic bag under strong wind.
Play the scene to see the simulation.
prompt
In order to improve the simulation results, improve
Simulation Precision
, this will be a major improvement at the cost of performance.
Cloak simulation
Let's be invisible in the Platformer3D demo.
note
You can download the Platformer3D demo on GitHub https://github.com/godotengine/godot-demo-projects/tree/master/3d/platformer or asset library .
Open the Player
scene, add a SoftBody
node and assign one to it PlaneMesh
.
Open the PlaneMesh
properties and set the size (x: 0.5 y: 1), and then set the Subdivide Width
sum Subdivide Depth
to 5. Adjusted SoftBody
position. You should end with the following form:
prompt
Subdivision will generate a more subdivided mesh for better simulation.
Add a BoneAttachment node under the bone node, and then select the "neck" bone to attach the cloak to the character bone.
note
The BoneAttachment node attaches the object to the bone of the armature. The attached object will follow the movement of the bones, and the weapon of the character can be attached in this way.
To create a fixed joint, select the higher vertex in the SoftBody node:
The fixed joint can be found SoftBody
in the Attachments
properties, select BoneAttachment
for SpatialAttachment
each fixed joint, the joint is fixed, and now it is fixed to the neck.
The last step is to avoid clipping by adding "Sport Body Player" to " SoftBody
of Parent Collision Ignore
".
Play the scene and the cloak should simulate correctly.
This covers the basic settings of the software and tried the parameters to achieve the desired effect when making the game.