set position for GameObject variable

i am very new in c# please help

using UnityEngine;
using System.Collections;
public class findtarget : MonoBehaviour {
public GameObject	   target ;
}

i want to know , How to set position(vector3) for target variable? i don’t understand about How to use Vector3 :face_with_spiral_eyes:

Thanks

target.transform.position = new Vector3(x, y, z);

Hi TCE! as laserlars refered in his example, you have first to make a reference to the GameObject you want to move, then refer to the “Transform” component of it, and then modify the position, where the Vector3 that contains the 3 coordinates in space are stored.

using UnityEngine;
using System.Collections;

public class findtarget : MonoBehaviour {

     public GameObject target;
     public Vector3 Destination = new Vector3(0,16,24); //Vector values ar random values for showing purposes

     void Start()
     {
          Move();
     }

     void Move()
     {
          target.transform.position = Destination;
     }
}

Thank you very much , it can useful for me :slight_smile:

I tried using this to set the rotation aswell because I have a block that falls, tumbles along the ground, but then I want it back to normal again. But when the timer finishes and the transform.position happens, it moves back to the start and rotates wildly in the air.

I used transform.rotation = new Vector3(XRot, YRot, ZRot);

The XRot and so forth are my public floats as I want 1 script for different positioned boxes.