お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。
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.
Close2つのコライダーの衝突判定を無効化します
これは例えば発射物が発射したオブジェクトに衝突しないようにする場合などに役に立ちます。
IgnoreCollision にはいくつかの制約があります:
1) 永続しない。つまりシーン保存したとき IgnoreCollision 状態はエディタに格納されません。
2) 有効なゲームオブジェクトにしか IgnoreCollision を適用できません。
コライダーまたはアタッチされた Rigidbody を無効化するとき IgnoreCollision 状態は失われ、再び Physics.IgnoreCollision を呼び出しする必要があります。
See Also: Physics.IgnoreLayerCollision.
// Instantiate a bullet and make it ignore collisions with this object. var bulletPrefab : Transform; function Start () { var bullet = Instantiate(bulletPrefab) as Transform; Physics.IgnoreCollision(bullet.collider, collider); }
using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { public Transform bulletPrefab; void Start() { Transform bullet = Instantiate(bulletPrefab) as Transform; Physics.IgnoreCollision(bullet.collider, collider); } }
import UnityEngine import System.Collections public class ExampleClass(MonoBehaviour): public bulletPrefab as Transform def Start() as void: bullet as Transform = (Instantiate(bulletPrefab) as Transform) Physics.IgnoreCollision(bullet.collider, collider)