Consider a Unity script attached to a GameObject with a BoxCollider and Rigidbody. What will be printed when this object collides with another?
void OnCollisionEnter(Collision collision) {
Debug.Log($"Collided with {collision.gameObject.name}");
}OnCollisionEnter is called only when both objects have colliders and at least one has a Rigidbody.
The method prints the name of the other GameObject involved in the collision. If the other object is named 'Player', it prints 'Collided with Player'.
In Unity 3D, which collider type lets objects pass through but still detects overlaps for events?
Triggers detect overlaps but do not cause physical collisions.
Setting isTrigger to true on any collider makes it a trigger collider, which detects overlaps but does not block movement.
Given this script on a GameObject with a SphereCollider set as trigger, why is OnTriggerEnter not called when another object enters?
void OnTriggerEnter(Collider other) {
Debug.Log("Trigger entered by " + other.gameObject.name);
}Triggers require at least one Rigidbody involved in the collision.
OnTriggerEnter is called only if one of the colliding objects has a Rigidbody. Without Rigidbody on the other object, the event won't fire.
Choose the correct syntax to set a MeshCollider's convex property to true in a Unity script.
MeshCollider meshCollider = gameObject.GetComponent<MeshCollider>();
Properties in C# are accessed without parentheses.
The convex property is a boolean property accessed directly with lowercase 'convex'. Methods like setConvex do not exist.
Given a GameObject with 1 BoxCollider and 1 SphereCollider, this code disables the BoxCollider and adds a CapsuleCollider. How many colliders are active?
BoxCollider box = gameObject.GetComponent<BoxCollider>(); box.enabled = false; CapsuleCollider capsule = gameObject.AddComponent<CapsuleCollider>();
Disabling a collider stops it from being active but does not remove it.
The BoxCollider is disabled (not active), the SphereCollider remains active, and the new CapsuleCollider is active. So total active colliders: 2.