Version: 2022.3
언어: 한국어

Physics.IgnoreCollision

매뉴얼로 전환
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.

설명

Makes the collision detection system ignore all collisions between collider1 and collider2.

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

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>()); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961