Version: 5.4
public static void IgnoreCollision (Collider collider1, Collider collider2, bool ignore= true);

説明

2 つのコライダーの衝突判定を無効化します

これは例えば発射物が発射したオブジェクトに衝突しないようにする場合などに役に立ちます。

IgnoreCollision は影響されたコライダーのトリガー状態をリセットします。そのため、この機能の呼び出しに応じて OnTriggerExit と OnTriggerEnter メッセージを受け取るかもしれません。

IgnoreCollision にはいくつかの制約があります:

1) 永続しない。つまりシーン保存したとき IgnoreCollision 状態はエディターに格納されません。

2) You can only apply the ignore collision to colliders in active game objects. When deactivating the collider or attached rigidbody the IgnoreCollision state will be lost and you have to call Physics.IgnoreCollision again. See Also: Physics.IgnoreLayerCollision.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public Transform bulletPrefab; void Start() { Transform bullet = Instantiate(bulletPrefab) as Transform; Physics.IgnoreCollision(bullet.GetComponent<Collider>(), GetComponent<Collider>()); } }