Physics software in game development

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 Spatialnew scene rooted at the node. Then, create a Softbodynode. Add CubeMeshin the meshproperties of the node in the inspector , and increase the subdivision of the mesh for simulation.

../../_images/softbody_cube.png

Set the parameters to obtain the desired software type. Try to keep Simulation Precision(simulation accuracy) above 5, otherwise, the software may collapse.

../../_images/softbody_cube_menu.png

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 Playerscene, add a SoftBodynode and assign one to it PlaneMesh.

Open the PlaneMeshproperties and set the size (x: 0.5 y: 1), and then set the Subdivide Widthsum Subdivide Depthto 5. Adjusted SoftBodyposition. You should end with the following form:

../../_images/softbody_cloak_subdivide.png

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.

../../_images/softbody_cloak_bone_attach.png

To create a fixed joint, select the higher vertex in the SoftBody node:

../../_images/softbody_cloak_pinned.png

The fixed joint can be found SoftBodyin the Attachmentsproperties, select BoneAttachmentfor SpatialAttachmenteach fixed joint, the joint is fixed, and now it is fixed to the neck.

../../_images/softbody_cloak_pinned_attach.png

The last step is to avoid clipping by adding "Sport Body Player" to " SoftBodyof Parent Collision Ignore".

../../_images/softbody_cloak_ignore.png

Play the scene and the cloak should simulate correctly.

../../_images/softbody_cloak_finish.png

This covers the basic settings of the software and tried the parameters to achieve the desired effect when making the game.

Guess you like

Origin blog.csdn.net/qq_44273429/article/details/111870621