【Unity】Collider忽略指定碰撞器

UnityEngine.Physics.IgnoreCollision(collider1, collider2, ignore);

//
// 摘要:
//     Makes the collision detection system ignore all collisions between collider1
//     and collider2.
//
// 参数:
//   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.
public static void IgnoreCollision(Collider collider1, Collider collider2, [Internal.DefaultValue("true")] bool ignore);

 在需要时调用上面API,填写需要互相忽略碰撞效果的碰撞器即可,第三参数填写true(默认为true)

猜你喜欢

转载自blog.csdn.net/qq_39574690/article/details/122745465