Physics2D.alwaysShowColliders = true;
????????附加到该Composite Collider的碰撞体需要勾选Used by Composite
Unity - Scripting API: Physics2D.IgnoreLayerCollision
Physics2D.IgnoreLayerCollision(8, 9,true);//忽略8与9层的碰撞
bool ignored = Physics2D.GetIgnoreLayerCollision(8 , 9 ); //检查8与9层的碰撞是否被忽略
- 检查某一点是否在某个碰撞器范围内:Physics2D.OverlapPoint ( pointPosition, layerMask )
void IsOnGround(Vector2 position)
{
Collider2D collider_Ground = Physics2D.OverlapPoint(position, 1 << LayerID_Ground);
if (collider_Ground != null)
{
Debug.Log("在地面上。");
}
Debug.LogWarning("!!!不在地面上");
}
|