Physics.IgnoreCollision

Cambiar al Manual
public static void IgnoreCollision (Collider collider1, Collider collider2, bool ignore= true);

Parámetros

collider1Any collider.
collider2Another collider you want to have collider1 to start or stop ignoring collisions with.
ignoreWhether or not the collisions between the two colliders should be ignored or not.

Descripción

Hace que el sistema de detección de colisiones ignore todas las colisiones entre collider1 y collider2.

Esto es útil, digamos, para prevenir que los proyectiles colisionen con los objetos que los disparan.

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.

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