Collider, Trigger, RigidBody

official explanation

  • Rigidbody: The Rigidbody component enables game objects to move under the control of a physical system. Rigid bodies can accept external forces and torques to ensure that game objects move as they do in the real world. Any game object can only be affected by gravity if a rigid body component is added. The force added to the game object through script and the operation of interacting with other game objects through the NVIDIA physics engine require the game object to add a rigid body component. 

    It is used to simulate the performance of an object when it is subjected to force, such as the parameters in the figure, Mass quality, Drag resistance, etc.
  • Collider: A collider is a type of physics component that needs to be added to a game object along with a rigid body to trigger a collision. If two rigid bodies collide with each other, the physics engine will not calculate the collision unless the two objects have colliders. In physics simulation, rigid bodies without colliders will pass through each other. 

    Including different Box Collider (box collider), Mesh Collider (mesh collider), etc. These colliders are applied in different occasions, but they must be added to GameObjecet.
  • Trigger: Check IS Trigger in the Collider panel to set it as a trigger.

Condition generated by collision (OnCollisionEnter/Stay/Exit can be called)

1. Both sides must have a collider, and the one that collides is the collider. 
2. One side of the movement must have a rigid body, and it does not matter whether the other side has a rigid body or not. 
Note: If the moving party has no rigid body, it will collide with the static rigid body, which is equivalent to not being installed. (Cannot call OnCollisionEnter/Stay/Exit)

Difference Between Collider and Trigger

1. The collider is the carrier of the trigger, and the trigger is just an attribute on the collider. 
2. When Is Trigger=false, the collider triggers a collision according to the physics engine to produce a collision effect, and the OnCollisionEnter/Stay/Exit functions can be called; 
3. When Is Trigger=true, the collider is ignored by the physics engine and there is no collision effect, you can call the OnTriggerEnter/Stay/Exit function.

When to use triggers

Triggers are useful when you want to detect contact of objects without having collision detection affecting object movement or to detect whether an object passes through an area in space.

Related experimental results

collision event

1. Control A (rigid body plus collision body) to hit stationary B (only collision body), and both parties can receive collision events. 
2. Control B (only the collision body) to hit the stationary A (rigid body plus collision body), and the two parties cannot receive the collision event.

Trigger events (both control A and B)

1.A (collision body), B (no collision body, whether there is a rigid body or not), no event is triggered. 
2.A (collision body), B (collision body), no events are triggered. 
3.A (collision body and rigid body, turn on IsTrigger), B (collision body, turn off IsTrigger), both parties can receive trigger events. 
4.A (collision body and rigid body, turn off IsTrigger), B (collision body, turn on IsTrigger), both parties can receive trigger events. 
5.A (collision body, IsTrigger turned off), B (collision body and rigid body, IsTrigger turned on), no events are triggered. 
6.A (collision body, IsTrigger turned on), B (collision body and rigid body, IsTrigger turned off), no events are triggered.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324646112&siteId=291194637