Version: 2023.2
言語: 日本語
public static void IgnoreCollision (Collider collider1, Collider collider2, bool ignore= true);

パラメーター

collider1 Any collider.
collider2 Another collider you want to have collider1 to start or stop ignoring collisions with.
ignore Whether or not the collisions between the two colliders should be ignored or not.

説明

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

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

Note that IgnoreCollision is not persitent. This means ignore collision state will not be stored in the editor when saving a scene.

If ignore is false, collisions can occur. Set ignore to true to ignore collisions.

Additional resources: 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>()); } }