Posts

Showing posts with the label transform

Changing position of gameObjects in unity by C# script

Image
Unity have a class for holding and changing value of a gameObject that is transform, by this class you can change position, rotation, and size of a gameObject.  transform have three methods for changing position of a gameObject. Let's take a look at all three methods - 1. transform.Translate() Method First method that transform class have is transform.Translate(). This method is useful when you want to move your gameObject to particular position so this method directly move your gameObject to given position. using   System . Collections ; using   System . Collections . Generic ; using   UnityEngine ; public   class   test  :  MonoBehaviour {      // Start is called before the first frame update      void   Start ()     {         transform . Translate ( 1,1,1 );// change position to 1,1,1    ...