Unity's collision body component

Source: Internet
Author: User

Collision Body component additions and settings in 3D physical components

Colliding bodies are a class of physical components, and 3D physical components and 2D physical components have unique collider components that are added to the game object with a rigid body to trigger collisions. If two rigid bodies collide with each other, the physical engine calculates collisions unless two objects have collisions, and in a physical simulation, the first experience without the collider crosses each other.

How to add a collision body to a 3D physical component: First select a Game object and then select the menu bar component→physics command to select a different collision body type so that the collider component is added to the object.

1. Box Collider (Box collision body).

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.

    • Edit Collider: Edits the collision body. Click the button to edit the collision body in the scene view.
    • is Trigger: Trigger. When selected, the collision body can be used to trigger events while ignoring physical collisions.
    • Material: Material. The different physical material types determine the interaction between the collision body and other objects, and click the button on the right to eject the physical Material selection dialog box.
    • Center: Centre. The position of the collision body in the object's local coordinates.
    • Size: sizes. The size of the collision body in the X, Y, and z directions.

2. Sphere Collider (Spherical collision body).

Spherical collider is a basic colliding body of a basic sphere. The three-dimensional size of spherical collider can be adjusted evenly, but it cannot adjust the size of an axis, which is suitable for objects such as falling stone and table tennis.

    • Edit Collider: Edits the collision body. Click the button to edit the collision body in the scene view.
    • is Trigger: Trigger. When selected, the collision body can be used to trigger events while ignoring physical collisions.
    • Material: Material. The different physical material types determine the interaction between the collision body and other objects, and click the button on the right to eject the physical Material selection dialog box to select a physical material for the collision body.
    • Center: Centre. The position of the collision body in the object's local coordinates.
    • Radius: Radius. The radius of the sphere collision body.

3. Capsule Collider (Capsule collision body).

The capsule collision body consists of a cylinder and two hemispheres connected to it, which is a basic collision body of capsule shape. The radius and height of the capsule collider can be individually adjusted for use in a character controller or in combination with other irregular shapes. The role controllers in unity often have capsule collisions embedded in them.

    • Edit Collider: Edits the collision body. Click the button to edit the collision body in the scene view.
    • is Trigger: Trigger. When selected, the collision body can be used to trigger events while ignoring physical collisions.
    • Material: Material. The different physical material types determine the interaction between the collision body and other objects, and click the button on the right to eject the physical Material selection dialog box to select a physical material for the collision body.
    • Center: Centre. The position of the collision body in the object's local coordinates.
    • Radius: Radius. This item controls the radius of the half-circle of the collision body.
    • Height: High. The item is used to control the height of the cylinder in the collision body.
    • 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 Collider (Mesh collision body).

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. the mesh collider that opens the convex parameter can collide with other mesh collisions.

    • Edit Collider: Edits the collision body. Click the button to edit the collision body in the scene view.
    • is Trigger: Trigger. When selected, the collision body can be used to trigger events while ignoring physical collisions.
    • Material: Material. The different physical material types determine the interaction between the collision body and other objects, and click the button on the right to eject the physical Material selection dialog box to select a physical material for the collision body.
    • Mesh: Mesh. Gets the mesh of the game object and takes it as a collision body.

The mesh collider sets the position and size proportions of the collider according to the transform component properties of the attached object. The collision grid uses a back effect, and if an object is visually colliding with a mesh with a back effect, then they are not physically colliding. 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 is less than 255.

5. Wheel Collider (Wheel collision body).

The wheel collider is a special collision body for ground vehicles. It has built-in collision detection, a wheel physical system and a reference body with a sliding tire friction. In addition to the wheels, the collider can also be used for other game objects.

  • Mass: Quality. This item is used to set the quality of the wheel collision body.
  • Radius: Radius. This item is used to set the radius of the wheel collision body.
  • Wheel damping Rate: The damping value of the wheel. This item is used to set the damping rate of the wheel.
  • Suspension Distance: Hanging distance. This is used to set the maximum elongation distance of the wheel collision body suspension, calculated according to the local coordinates. The suspension is always extended by the y-axis of its local coordinates.
  • Force app Point Distance: The distance between the forces applied points. This defines the distance between the point of the wheel force and the horizontal minimum of the wheel. When this parameter is 0 o'clock, the wheel force will be applied to the lowest point of the wheel collider along the y-axis of its parent object, and it will be better to place the point slightly below the vehicle's center of mass.
  • Center: Centre. This item is used to set the wheel collision body at the center of the object's local coordinates.
  • Suspension Spring: Suspension spring. The item is used to set the wheel collider by adding springs and damping forces to make the suspension reach the target position.
    • Spring: Springs. The greater the spring force, the faster the suspension will reach its destination.
    • Damper: Damper. The damper controls the speed of the suspension, the larger the value the more slowly the suspension spring moves.
    • Target Position: Destination location. The distance at which the suspension is stationary along its direction. A value of 0 o'clock is suspended for full stretch, a value of 1 is fully compressed, and the default value is 0, which matches the normal car suspension state.
  • Forward friction: Forward friction. The friction property when the tyre is rolling forward.
    • Extremum slip: Sliding extremum.
    • Extremum value: Limit values.
    • Asymptote slip: Sliding progressive value.
    • Asymptote Value: Progressive.
    • Stiffness: stiffness factor. The limit value and the multiplier of the progressive value (default is 1), the stiffness changes the friction. When set to zero, all wheel friction is disabled. It is common to simulate various ground materials at run time by modifying the stiffness of the script.
  • Sideways friction: lateral friction. The friction property when the tyre is rolling sideways.
    • Extremum slip: Sliding extremum.
    • Extremum value: Limit values.
    • Asymptote slip: Sliding progressive value.
    • Asymptote Value: Progressive.
    • Stiffness: stiffness factor. The limit value and the multiplier of the progressive value (default is 1), the stiffness changes the friction. When set to zero, all wheel friction is disabled. It is common to simulate various ground materials at run time by modifying the stiffness of the script.

The collision detection of a wheel is achieved by projecting a ray upward from the local coordinate y-axis. The wheel has a radius that extends downward through the suspension distance, and the vehicle can be controlled by different attribute values in the script. These attribute values are Motortorque (engine torque), braketorque (Braking torque), and steerangle (steering angle). The wheels collide with the rest of the sports physics engine by using a reference body based on sliding friction to calculate the friction separately. This results in more realistic interaction, but the wheel collision is not affected by the physical material.

① Wheel Collider Setup: There is no need to control the vehicle by reversing or scrolling the game object to which the wheel collider is bound, because the game object that binds the wheel collider is fixed in itself relative to the car. However, the best way to reverse or roll a wheel is to set it apart from the wheel colliding body and the visible wheels.

The geometry of the ② collision body: Because the vehicle has a certain speed, it is very important to create a reasonable collision assembly. In particular, the collision meshes that make up the invisible model should not have a small uneven appearance. The collision grids of the general track can be made separately, which makes them smoother.

6, Terrain Collider (Terrain Collider).

Terrain Collider is a collision body built on terrain.

    • 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.
    • Terrain data: terrain. Using different terrain data to determine the appearance of the terrain, click the Circle button on the right to pop up the Terrain Data Selection dialog box, you can select a terrain data for the collision body.
    • Enable Tree Collider: Open the collision body of the trees. If this key is turned on, the collision body of the tree will be enabled.

Article from "Unity official case explaining"

Unity's collision body component

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.