Physics, colliders and triggers
Colliders define shape; Rigidbodies make physics act on an object.
What you will be able to do
- One Rigidbody per physics object, not one per child collider.
- Use layer masks to control what can collide.
- Do not move a Rigidbody by changing Transform directly.
In plain English
Use a Rigidbody for objects that move under physics. Colliders without a Rigidbody are static. Triggers detect overlap without blocking. Put collision responses in a component that has the context to decide what happens.
using UnityEngine;
public class Pickup : MonoBehaviour
{
private void OnTriggerEnter(Collider other)
{
if (!other.CompareTag("Player")) return;
GameManager.Instance.AddScore(10);
Destroy(gameObject);
}
}Your turn
MediumCollect a pickup
On trigger enter by the Player, add 10 score and destroy the pickup.
CSHARP · starter
private void OnTriggerEnter(Collider other) {}Check your understanding before moving on.
Knowledge checkQuestion 1
What is the difference between a collider and a trigger?
Select an answer to continue
Study tools
Make it yours.
Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.
Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign inFinished reading?
Lock in what you just learned.
0%
Mark this lesson complete to save your place and move one step closer to the certificate.