1. Trigger trigger: Tick Istrigger Properties
Trigger detection Occurs when the player has just entered the triggering area
void Ontriggerenter (Collider other)
{
if (Other.tag = = "Player")
{
Todo
}
}
Trigger detection Occurs when the player is in the trigger area
void Ontrigglestay (Collider other)
{
if (Other.tag = = "Player")
{
Todo
}
}
2. Collider collision: Without checking the Istrigger attribute , two colliding objects have Collider (Collider), and one object must also have a rigidbody rigid body. (usage is similar to the above)
The difference between the two:
1. Tick the Istrigger property (Trigger), no impact effect, such as: people standing close to the door of the door automatically open the effect
Do not tick the Istrigger property (collision), there is a collision effect, such as: The car was crashed, the ball fell on the ground and bounce effect
2. Trigger Trigger can pass through.
Unity_ small function implementation (collision detection)