Show Menu
Cheatography

Unity 3D (C#) - Common Functions Cheat Sheet (DRAFT) by

Common Unity 3D functions/snippets

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Collisions

Discrete (default)
Continuous
Continuous Dynamic
Continuous Specul­ative
Checks for collisions on each physics step
The collider is cast forward, similar to box casting. Which makes it far more accurate than Discrete
Collides with objects that contain a rigid body (and are not static)
Draws a bounding box around the current object, and a predicted position according to its movement
Depends on the 'Fixed Timestep' value defined in Project Settings > Time
The collider only collides with static objects
Typically used when you need to collide two moving objects
Works with both, static and dynamic colliders. But, it suffers from ghost collisions whereby an object may hit a collision prior to touching.

Assets

C# Principles

(condi­tion1 && condit­ion2) ? true : false
A single line condit­ional statement
public <ty­pe> <na­me> {get; set;}
Single­-line property creation (prop in VS)
public Apple(­string newColor) : base(n­ewC­olor)
This specifies the parent constr­uctor if a constr­uctor is not already present

Common Code Snippets

Parent­Gam­eOb­jec­t.t­ran­sfo­rm.G­et­Child (0)
Get child component of GameObject
Rigidb­ody.Ad­dTo­rqu­e((­Vector3 torque, ForceMode mode = ForceM­ode.Force)
Continuous force along the direction of the force vector

Useful Links