Complete the code to add a BoxCollider component to the GameObject.
gameObject.AddComponent<[1]>();The BoxCollider component adds a box-shaped collider to the GameObject, which is used for 3D collision detection.
Complete the code to check if the GameObject has a Collider component.
if (gameObject.GetComponent<[1]>() != null) { Debug.Log("Collider found"); }
The Collider class is the base class for all 3D colliders. Checking for it detects any collider type.
Fix the error in the code to detect collision with another object.
void OnCollisionEnter(Collision [1]) { Debug.Log("Collided with " + [1].gameObject.name); }
The parameter name in OnCollisionEnter is commonly collision. It represents collision info.
Fill both blanks to create a dictionary of GameObjects and their BoxCollider sizes where the size's x dimension is greater than 1.
var bigColliders = new Dictionary<GameObject, Vector3>() {
{ [1], [2].size }
};We use gameObject as the key and get the BoxCollider component to access its size property.
Fill all three blanks to create a dictionary comprehension that maps GameObjects to their collider bounds size if the collider is enabled and size x is greater than 0.5.
var colliderSizes = new Dictionary<GameObject, Vector3>() {
{ [1], [2].bounds.size }
} where [3].enabled && [2].bounds.size.x > 0.5;The key is the gameObject. We get the Collider component to access bounds.size and check if it is enabled and size x is greater than 0.5.