You are on page 1of 10

Unity Physics

Because, why not?


Unity Physics Options: 3D
• Colliders
• Rigidbodies
• Physics Force
• Physics Torque
• Physics Material
• Physics Joints
• Detecting Collisions
• Raycasting
Colliders
• Colliders are a component that allows the game object they're
attached to react to other colliders provided that one of the game
objects has a rigidbody component attached.
• Colliders come in various shapes and types, and are denoted in the
scene view by a green outline.
• They can have the following primitive shapes: a sphere, a capsule and
a box.
• For more complex shapes, you can either:
• Combine several of these shapes; or
• Mesh Collider
Collision Methods
Methods:

OnCollisionEnter OnCollisionEnter is called when this collider/rigidbody has begun touching another
rigidbody/collider.

OnCollisionExit OnCollisionExit is called when this collider/rigidbody has stopped touching another
rigidbody/collider.

OnCollisionStay OnCollisionStay is called once per frame for every collider/rigidbody that is touching
rigidbody/collider.

OnTriggerEnter OnTriggerEnter is called when the Collider other enters the trigger.
OnTriggerExit OnTriggerExit is called when the Collider other has stopped touching the trigger.
OnTriggerStay OnTriggerStay is called almost all the frames for every Collider other that is touching the trigger.
OnCollision
• Uses the Collision class where it contains contact points, velocity,
impact etc.
• void OnCollisionEnter(Collision coll)
• Called once on entry of the colliders to each other
• void OnCollisionStay(Collision coll)
• Called every frame as long as the colliders were touching each other
• void OnCollisionExit(Collision coll)
• Called once on exit of the colliders
OnTrigger
• Uses the Collider class.
• Only works on the following conditions
• An object with the IsTrigger property checked on the collider inspector
• A rigidbody attached to one of the objects
• void OnTrigger Enter(Collider coll)
• Called once on entry of the colliders to each other
• void OnTrigger Stay(Collider coll)
• Called every frame as long as the colliders were touching each other
• void OnTrigger Exit(Collider coll)
• Called once on exit of the colliders
Rigidbody
• Rigidbodies are components that allow a game object to be effected by physics.
• They allow the object to fall under gravity, and have physics properties such as
mass, drag and velocity.
• Mass
• The mass of the object effects how collisions are treated with the object.
• Game objects with a higher mass will react less when collided with a lower mass game
object
• Drag
• Drag - The drag of a game object effects how quickly it will slow down without other
interactions. It's used to determine the rate of a loss of linear velocity.
• Angular Drag - It's used to determine the rate of a loss of angular velocity.
Rigidbody
• Use gravity
• duh
• Is Kinematic
• Sets on whether the rigidbody will react to external forces or not
• Interpolate/Extrapolate
• To reduce jittering on the physics
• Collision Detection
• Discrete – By default, reacts to any physic interaction being used on the scene
• Continuous – Used for fast moving objects to static ones
• Continuous Dynamic – Used for fast moving objects to dynamic ones
• Constrains
• Constrains the movement and rotation of a rigidbody to a certain axis
Activity
• Create a “skaters ramp” out of primitive objects in Unity
• Allow several objects to free fall and hinder the movements of
dynamic objects

You might also like