0
0
Unityframework~10 mins

Trigger vs collision detection in Unity - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to detect when an object enters a trigger collider.

Unity
void OnTriggerEnter(Collider [1]) {
    Debug.Log("Object entered trigger");
}
Drag options to blanks, or click blank then click option'
Acollision
Bcol
Cother
Dhit
Attempts:
3 left
💡 Hint
Common Mistakes
Using collision instead of other in OnTriggerEnter.
Forgetting to include the parameter.
2fill in blank
medium

Complete the code to detect when two colliders collide (not triggers).

Unity
void OnCollisionEnter(Collision [1]) {
    Debug.Log("Collision detected");
}
Drag options to blanks, or click blank then click option'
Ahit
Bother
Ccol
Dcollision
Attempts:
3 left
💡 Hint
Common Mistakes
Using other instead of collision in OnCollisionEnter.
Confusing trigger and collision methods.
3fill in blank
hard

Fix the error in the method name to detect trigger exit events.

Unity
void On[1]Exit(Collider other) {
    Debug.Log("Object exited trigger");
}
Drag options to blanks, or click blank then click option'
ATrigger
BCollision
CCollider
DTriggerEnter
Attempts:
3 left
💡 Hint
Common Mistakes
Using OnCollisionExit for trigger events.
Misspelling the method name.
4fill in blank
hard

Fill both blanks to correctly check if the collider is a trigger and log a message.

Unity
void OnCollisionEnter(Collision [1]) {
    if ([2].collider.isTrigger) {
        Debug.Log("Triggered by a trigger collider");
    }
}
Drag options to blanks, or click blank then click option'
Acollision
Bother
Attempts:
3 left
💡 Hint
Common Mistakes
Using other as parameter name but collision inside the method.
Checking isTrigger on the wrong object.
5fill in blank
hard

Fill all three blanks to create a method that detects trigger stay events and logs the name of the other object.

Unity
void On[1]Stay(Collider [2]) {
    Debug.Log($"Object [3] is staying in trigger");
}
Drag options to blanks, or click blank then click option'
ATrigger
Bother
C{other.name}
DCollision
Attempts:
3 left
💡 Hint
Common Mistakes
Using OnCollisionStay instead of OnTriggerStay.
Forgetting to use string interpolation for the object's name.