Collision Detection, Prefabs Unity Notes Collision Detection, Prefabs
Colliders Unity components that handle collisions Basic shapes: box, sphere, capsule Custom shape: mesh
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
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
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)
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