Version: 2022.3
Language : English
Collider interactions
OnCollision events

Use collisions to trigger other events

When two collidersAn invisible shape that is used to handle physical collisions for an object. A collider doesn’t need to be exactly the same shape as the object’s mesh - a rough approximation is often more efficient and indistinguishable in gameplay. More info
See in Glossary
make contact, they call functions that you can use to trigger other events in your project. You can place any code you like in these functions to respond to the collisionA collision occurs when the physics engine detects that the colliders of two GameObjects make contact or overlap, when at least one has a Rigidbody component and is in motion. More info
See in Glossary
event.

Collider events require configuration via C# script; you cannot configure them using only the user interface.

There are two collider event types:

A collider that has Is Trigger enabled is called a trigger collider. Trigger colliders do not physically collide with other colliders; instead, they create a space that sends an event when other colliders pass through it.

Note: The 2D physics system has equivalent functions with 2D appended to the name (for example, OnCollisionEnter2D). For details of these 2D functions, refer to the MonoBehaviour API class documentation.

Collider interactions
OnCollision events
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961