Recommended reading
- CSDN home page
- GitHub open source address
- Unity3D plugin sharing
- Jane’s address book
- My personal blog
- QQ group: 1040082875
I. Introduction of plug-ins
Exploder is an Unity3D plugin that explodes any gameobject with a grid. Set tag to “Exploder” on your game object and watch it explode!
Plug-in download:
Download.csdn.net/download/q7…
How do plug-ins work
This plugin includes a powerful grid cutter that can find grids in your gameobjects.
It then recursively cuts the grid into smaller pieces, assigning rigid-body and velocity to each piece, and creates an explosion.
For best performance, shards are pre-allocated in a pool.
The cutting algorithm is very fast, and the calculation time is up to one frame, so it does not have a big impact on FPS and memory, but also can see very powerful explosion effect.
Three, fast start
It’s easy to use: 1. Add an Exploder prefab to your hierarchy
2. Set component parameters
Add a script that calls ExplodeObject
using UnityEngine;
using Exploder.Utils;
public class ExplodeTest : MonoBehaviour
{
public GameObject TagerObject;
void Start(){ ExploderSingleton.Instance.ExplodeObject(TagerObject); }}Copy the code
Fourth, Demo introduction
DemoQuickStart Quickly starts Demo
Generate a ball, click the Button Explods Sphere, and the little ball explodes.
DemoClickExplode
Click on any gameobject and the gameobject will explode
DemoShooter a first-person shooter scene
Its basic idea is: (1) add explosion presets to the scene. (2) Set up your weapon and camera), shoot with the mouse (3) run the light cast from the direction of the camera at the same time. (4) Get a clicked gameobject (such as a vase). (5) Move the Exploder prefab to the position of the gameobject you clicked on (for example, now the ExploderObiect is in the same position as the vase) (6) Set the explosion scope of the preform by calling ExplodeRadius() to explode the scope; If you want to shoot an object you can use ExplodeObject() (7)
ExploderObject
Main Settings
The name of the | instructions |
---|---|
Radius | Blast radius, the blast radius that can be destroyed |
Force | Force is the amount of physical force added to the explosive fragments. More force means more speed. |
Target Fragments | The amount of debris that will be created by cutting through an explosive object. More fragmentation means more computation and |
Use Force Vector | This option is valid only when UseForceVector is true. The thruster represents the three-dimensional vector direction in which the explosive particle will move. |
Ingnore Tag | Ignore mark exploitable object. Setting this to true will allow objects to explode without having to tag them |
Explode self | Indicates whether to preserve the Exploder object after an explosion, if checked, the explosion will be destroyed |
Hide self | Mark after the explosion whether to hide the object of the explosion, cleavage check, the explosion will be hidden |
Delete original object | Delete original game object after explosion. |
Uniform distrubution | By enabling this Exploder, the same number of shards are created for each object, regardless of the object’s distance from the center. By default, objects near the center (the center of the explosion) will be shattered into more pieces than objects farther away. An even distribution will ensure that all objects will be shattered into the same number of pieces |
Split mesh islands | Select separate unconnected parts of the same grid. If this option is enabled, all explosive fragments are searched by connecting parts of the same grid and these parts are separated into new fragments |
Disable triangulation | By enabling this explosive, each object produces a certain amount of debris, regardless of its distance from the center. By default, closer to the explosion) breaks into more pieces than farther away. |
Use 2D physics | Enable 2D objects. |
Use Cube Raius | Using Cube radius |
Multi-threading | The Exploder supports multithreading, and you can choose up to three additional threads to compute. Threads are initialized at startup, but in hibernation are used only when needed |
Cutting plane angle | Angle of section |
Fragments options set
The name of the | instructions |
---|---|
Pool Size | Object pool size, which represents the maximum number of all available shards, which should be higher than the target shard. |
Explodable fragments | The shard that can destroy the shard, if checked, can destroy the object, then all its shards. You can keep breaking pieces until they are small enough |
Layer | Name of the shard layer |
Mesh colliders | Turn on grid collider |
MaxVelocity | Maximum speed |
MaxAngularVelocity | Maximum angular velocity |
Inherit parent physics | By enabling this fragment, the same physical properties as its parent rigidbody are used. It will inherit mass, velocity, angular velocity, and use gravity. If there is no valid parent rigidbody, the default Settings are used instead. |
Mass | Mass of fragments |
Use gravity | Enable gravity |
Angular velocity | If Inherit parent Physics is enabled, the final angular velocity will be calculated as the sum of the parent physics and this value. |
Random angular vector | Random angular velocity |
Freeze Position | The location of the frozen debris. |
Freeze Rotation | The rotation of frozen debris. |
Material | Optional material fragment, if default material is not selected |
Six, the summary
Remember to use one button three times oh