Presentation is loading. Please wait.

Presentation is loading. Please wait.

Collision Detection, Prefabs

Similar presentations


Presentation on theme: "Collision Detection, Prefabs"— Presentation transcript:

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


Download ppt "Collision Detection, Prefabs"

Similar presentations


Ads by Google