Hello
I am Working in 3d, my game is there is a sphere it goes up on tapping. Now what I want is, I want a game object to spawn x units below the sphere everytime sphere goes 30 units up(I am working in y axis) I have worked out the sphere going up 30 units and instantiating game object but I can’t find a way to spawn it x units below the sphere, irrespective of the position of sphere. Any help is appreciated, thanks
I am still very new to unity
You take the transform.position of the sphere, which is its world space position, and just create a new Vector3 based on that position but x units lower.
float xUnitsLower = 30f;
Vector3 newInstantiateObjectPosition = new Vector3(transform.position.x - xUnitsLower, transform.position.y, transform.position.z);
Then you just instantiate the prefab, and either pass the new position you want for the object in the instantiate call itself, or just assign the position to the returned object’s transform immediately after.[/code]