private void SetWallStates(Collider2D collider, bool state) { if (!state) { onRightWall = state; onLeftWall = state; return; } Collider2D[] points = new Collider2D[5]; collider.GetContacts(points); if (points.Contains(right)) { onRightWall = state; } else if (points.Contains(left)) { onLeftWall = state; } }
public void CheckCollision() { GetCollider(); Collider2D[] exitCollider = new Collider2D[6]; int count = 0; foreach (Collider2D c in oldCollider) { if (!nowCollider.Contains(c)) { exitCollider[count] = c; count++; } } ContactFilter2D filter; Collider2D[] colliders = new Collider2D[6]; filter = new ContactFilter2D(); collider.OverlapCollider(filter, colliders); count = 0; foreach (Collider2D c in colliders) { if (c == null) { continue; } if (exitCollider.Contains(c)) { Destroy(c.gameObject); ballCount++; GameManager.score += score; //UIManager.SetText("BallCountText", "入った数:" + ballCount); } } oldCollider = nowCollider; nowCollider = new Collider2D[6]; }
public void Examine(InputAction.CallbackContext context) { if (context.ReadValueAsButton() && _examining) { _examining = true; var newlyVisible = new Collider2D[_maxVisible]; var contactFilter = new ContactFilter2D { layerMask = layerMask, useLayerMask = true }; if (_lineOfSight.OverlapCollider(contactFilter, newlyVisible) > 0) { for (int i = 0; i < _visible.Length; i++) { if (!newlyVisible.Contains(_visible[i])) { } } } } else if (!context.ReadValueAsButton()) { _examining = false; } }