Version: 5.3 (switch to 5.4b)
언어English
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

MonoBehaviour.OnTriggerStay(Collider)

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.

닫기

Submission failed

For 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.

닫기

취소

Switch to Manual

파라미터

other The other Collider involved in this collision.

Description

OnTriggerStay는 트리거를 건드리고 있는 각각/ 다른 / Collider에 대해서 매 프레임 당 한번 호출됩니다.

이 메시지는 트리거 및 트리거가 닿은 콜라이더에 전송됩니다. Notes: Trigger events are only sent if one of the colliders also has a rigidbody attached. Trigger events will be sent to disabled MonoBehaviours, to allow enabling Behaviours in response to collisions.

	// Applies an upwards force to all rigidbodies that enter the trigger.

function OnTriggerStay (other : Collider) { if (other.attachedRigidbody) other.attachedRigidbody.AddForce(Vector3.up * 10); }
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void OnTriggerStay(Collider other) { if (other.attachedRigidbody) other.attachedRigidbody.AddForce(Vector3.up * 10); } }

OnTriggerStay can be a co-routine, simply use the yield statement in the function.