Categories: Unity, C #, VS2015
Date Created: 2016-05-02 I. INTRODUCTION
A collision component (Collider) is another component that must be added with a rigid body (rigidbody) to allow it to collide with other components. Alternatively, if only two rigid bodies (rigidbody) collide with each other, the physics engine does not calculate collisions unless both objects have a collision component (Collider) attached.
Non-collision components (Collider) Rigid bodies (Rigidbody) only pass through each other during physical simulations. Ii. Basic Concepts
1. How to add a collision body
First select a Game object, then open the menu "Component"--"Physics" option, select a different collision body type, so that the object is added to the collision body component.
2. Collision Body
The interaction between the collision body and the rigid body makes the game object have physical effect, the rigid body can make the object be controlled and influenced by the physical effect, and the collision body can cause the object to collide with each other. Colliding bodies do not necessarily need to bind rigid bodies, but rigid bodies must bind a collision body to an object to have a collision effect.
When two collisions collide and at least one of them adds a rigid body, three collision messages are sent to the objects that bind them, which can be handled by the script and allow the user to create a unique correlation behavior.
3. Trigger
If you want the collision body to take effect and treat it as a trigger, you can turn on the is trigger property in the Lnspector view.
Triggers are not controlled by the physical engine, and three trigger messages are sent when a trigger collides. Triggers are useful for triggering various events in the game, such as switching scenes, automatic door opening, display help tutorials, and more. Of course, in order for two objects that apply triggers to send a trigger event during a collision, one of the objects must have a rigid component.
4. Friction and elasticity
Friction, elasticity and softness are determined by the physical material, and unity provides a physical material resource bundle that contains most of the common physical materials, which can be used directly after import. Of course you can also create a new physical material and adjust its parameters, properties. Three, the basic collision body
The collision body includes a sphere collision body (Sphere Collider), a Box collision body (Box Collider), a mesh collision body (mesh Collider), a physical material (Physics Material), a hinge joint (Hinge Joint), a spring joint ( Spring Joint) and so on.
1, Box collision body (Box Collider)
The Box collision body (Box Collider) is a basic cube-shaped collision primitive.
The box collision body is a basic collision body of a cubic shape. The collision body can be adjusted to a different size box, can be used as a door, wall and platform, but also for dolls role trunk or car, such as the shell of vehicles, of course, the most suitable for use in boxes or boxes.
(1) is Trigger
Trigger. Tick the top, the collision body can be used to trigger the event and will be ignored by the physical engine.
(2) Material
Material. The different physical material types determine the interaction between the collision body and other objects, and click the Circle button on the right to eject the physical Material selection dialog box.
(3) Center
Center. The position of the collision body in the object's local coordinates.
2, spherical collision body (Sphere Collider)
Spherical Collider (Sphere Collider) is a basic spherical collision primitive.
Sphere collision body Three-dimensional size can be evenly adjusted, but not individually adjust the size of an axis direction, the collision body for falling stone, table tennis and other game objects.
(1) is Trigger
Trigger. If this key is turned on, the collider can be used to trigger the event and will be ignored by the physical engine.
(2) Material
Material. The different physical material types determine the interaction between the collision body and other objects, and click the Circle button on the right to eject the physical Material selection dialog box to select a physical material for the collision body.
(3) Center
Center. The position of the collision body in the object's local coordinates.
(4) Radus
Radius. The size of the spherical collision body.
3. Capsule colliding body (Capsule Collider)
The capsule collision body consists of a cylinder and a two hemisphere connected to it, which is a basic colliding body of the adhesive shape.
The radius and height of the capsule collider can be individually adjusted to use in a character controller or in combination with a collision with a real irregular shape.
A player in unity usually has a capsule collider embedded in it.
(1) is Trigger
Trigger. If this key is turned on, the collider can be used to trigger the event and will be ignored by the physical engine.
(2) Direction
Direction. The axis of the capsule's longitudinal direction in the object's local coordinates, which is the y-axis by default.
4. Mesh Collision Body (mesh Collider)
Mesh Collider uses a grid resource (mesh Asset) and builds its collision body (Collider) based on the mesh. For collision detection, this is much more accurate than using primitives for complex meshes. A mesh collision body (mesh Collider) marked as a convex body (convex) can collide with other mesh collisions (mesh Collider).
Creates a collision body (Collider) from the mesh of an object, and cannot collide with other mesh collisions (mesh Collider)
Mesh collider, by acquiring mesh objects and building collisions on top of them, is more granular than using basic collisions on complex mesh models, but consumes more system resources.
(1) is Trigger
Trigger. If this key is turned on, the collider can be used to trigger the event and will be ignored by the physical engine.
(2) Convex
Convex: convex. The mesh collider that opens the convex parameter can collide with other mesh collisions.
Tick the top, the mesh collider will collide with other mesh collisions. Mesh Collider in accordance with the transform component properties of the attached object does not set the position and size ratio of the collision, the collision mesh uses the back blanking method, if an object with a back-blanking mesh in the visual collision, then they do not physically collide.
There are some limitations to using the mesh collider: Usually there is no collision between the two mesh collisions, but all mesh collisions can collide with the basic collision body. If the convex parameter of the collision body is set to ON, it will also collide with other mesh collisions. It is important to note that the convex parameter will only take effect if the number of triangles in the mesh collider mesh is less than 255.
"Unity" 11.3 Basic collider (box, sphere, capsule, mesh)