Physics.IgnoreCollision

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

Parámetros

startStarting point of the collider.
endEnd point of the collider.
ignoreIgnore collision.

Descripción

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

This is useful, say, for preventing projectiles from colliding with the object that fires them.

Note that IgnoreCollision will reset the trigger state of affected colliders, so you might receive OnTriggerExit and OnTriggerEnter messages in response to calling this. IgnoreCollision has a few limitations:

1) It is not persistent. This means ignore collision state will not be stored in the editor when saving a scene.
2) Sólo puede aplicar la ignore collision (ignorar colisiones) a colliders en game objects activos.

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