Hi everyone i made a script that spawning clones of some object but that is not spawning there where is my mouse can u help?
respawn - a field where we should click to spawn a object
dolar - object
public GameObject respawn;
public GameObject dolar;
private Transform trans;
private void Start()
trans = respawn.GetComponentInChildren<Transform>();
private void Update()
dolar = Instantiate(dolar, new Vector3 (0,0,0), trans.rotation);
dolar.transform.parent = GameObject.Find("GameObject").transform;
You are very close!
You first instantiate it at the center of the Scene, at VEctor3.zero.
Then you make it child of another object.
If what you want is that the object apears at the parents position, You only need now to move it to the center of its parent (or the relative position you want)
dolar.transform.Localposition = Vector3.zero;
PD: You have an object in the scene called GameObject? Thats very baad practice maaan! change its name! GameObject is the basic variable name for objects, and you will get in trouble if use that word as a name…