Best Practices

Code

Degrees And Radians

Prefix angle variables and functions with d_ or r_

The Unity API switches between degrees and radians. This can create very hard to identify intermittent bugs that can take a lot of laborious stepping through code to resolve. Code defensively by prefixing your variables and functions with d_ and r_ .

WRONG!

float axial, elevation, radius;
SphericalToCartesian(axial,elevation,radius);

CORRECT

float d_axial, d_elevation, radius;
r_SphereicalToCartesian(d_axial,d_elevation,radius);

Notice how easy it is to spot the bug before it happens with the naming convention.

Coroutines

Be careful using yield return WaitForEndOfFrame. It is connected to the rendering routines. If VSynch is being used then this may not be called every frame. Instead use yeild return null.