public bool IsCollisionEnabled(IBody rigidBody1, IBody rigidBody2) { if (gameObjectMap.ContainsKey(rigidBody1) && gameObjectMap.ContainsKey(rigidBody2)) { return(LayerCollisionMatrix.CollisionEnabled(gameObjectMap[rigidBody1], gameObjectMap[rigidBody2])); } return(true); }
// BUSINESS LOGIC public void SetCollisionLayer(int i_Layer) { if (m_Body != null) { int layerMask = (1 << i_Layer); int collisionMask = LayerCollisionMatrix.ComputeCollisionMask(i_Layer); m_Body.CollisionCategories = (Physics2D.Category)layerMask; m_Body.CollidesWith = (Physics2D.Category)collisionMask; m_Body.CollisionGroup = 0; // Forced to zero, unused. } }
/** * @brief Check if the collision between two RigidBodies is enabled. * * @param rigidBody1 First {@link RigidBody} * @param rigidBody2 Second {@link RigidBody} **/ public bool IsCollisionEnabled(IBody rigidBody1, IBody rigidBody2) { return(LayerCollisionMatrix.CollisionEnabled(gameObjectMap[rigidBody1], gameObjectMap[rigidBody2])); }