Download presentation
Presentation is loading. Please wait.
1
Collision Detection, Prefabs
Unity Notes Collision Detection, Prefabs
2
Colliders Unity components that handle collisions
Basic shapes: box, sphere, capsule Custom shape: mesh
3
Rigidbody Gives an object mass and puts it under control of Unity’s physics engine At least 1 colliding body must have a rigidbody component to get collision events Can turn off gravity Can be “kinematic” or unaffected by physics
4
Mouse Events To register mouse events, an object must have a collider
Implement OnMouseEnter, OnMouseOver, OnMouseDown, OnMouseUp… Mouse position (screen coordinates) given by Input.MousePosition
5
Collisions Entities with colliders (at least one rigidbody) get collision events Implement the OnCollisionEnter(Collision c) method The collision object has lots of information – the one you probably want is c.gameObject (the object you collided with)
6
Prefabs Prefabs are objects that may not be in the scene yet
Can be instantiated to add to the scene Similar to cloning an object
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.