Suggest a change Success!Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable. Close Submission failedFor some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation. Close Your name Your email Suggestion* Cancel Switch to Manual Parameters
DescriptionSent when another object enters a trigger collider attached to this object (2D physics only). Further information about the other collider is reported in the Collider2D parameter passed during the call. This message is sent to the trigger Collider2D and the Rigidbody2D (if any) that the trigger Collider2D belongs to, and to the Rigidbody2D (or the Collider2D if there is no Rigidbody2D) that touches the trigger. Note: Trigger events are only sent if one of the Colliders also has a Rigidbody2D attached. Trigger events are sent to disabled MonoBehaviours, to allow enabling Behaviours in response to collisions. See Also: Collider2D class, OnTriggerExit2D, OnTriggerStay2D. The following two script examples create an OnTriggerEnter2D demo. Example1 generates a Unity logo sprite, Example2. This is the sprite that moves forwards and backwards and triggers with Example1. using System.Collections; using System.Collections.Generic; using UnityEngine; Suggest a change Success!Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable. Close Submission failedFor some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation. Close Your name Your email Suggestion* Cancel Parameters
DescriptionSent when another object enters a trigger collider attached to this object (2D physics only). Further information about the other collider is reported in the Collider2D parameter passed during the call. Trigger events will be sent to disabled MonoBehaviours, to allow enabling Behaviours in response to collisions. See Also: The Collider2D class and the OnTriggerExit2D and OnTriggerStay2D messages. An OnTriggerEnter2D example is shown. This example has two empty GameObjects, called The script below is Example1. using System.Collections; using System.Collections.Generic; using UnityEngine; This is using System.Collections; using System.Collections.Generic; using UnityEngine; |