Programming Adventures 2 - Unity3D Translation

Programming Adventures 2 - Unity3D Translate

When moving objects using gameObject.transform.translate(x,y,z), its direction is based on the object's local transformation.

That means that a square object rotated 90 degrees right will translate +Y when translated by (10, 0, 0).

This bug happens when trying to translate objects using world space vectors.


The solution is to use gameObject.transform.SetPositionAndRotation( gameObject's position + translation direction, __); this avoids the local transformation stack!


Popular posts from this blog

Ten Golden Usability Rules

Programming Tricks 1 - PHP and JS/CSS