- Home /
How can i set a prefab to x=0 and y=0.
I put a part of a game in a game object folder. I saved the gamefolder as a prefab. But wat i didn't realize is that the prefab starts at x=5 and y=0,04. is there any way to set the prefab to x=0 and y=0 as a standard without having to remake the game.
Answer by MccoringPL · Sep 06, 2017 at 04:07 PM
You just need change position of prefab in prefab inspector to 0 0 0 if i understood what you sayed (im not good in english)
Answer by Divinegaming · Sep 06, 2017 at 04:09 PM
I assume you are talking about Instantiating a prefab at run time.
The Instantiate
method allows you to set an objects position and rotation when it is created.
Instantiate(prefab, Vector3.zero, Quaternion.identity);
see docs for more https://docs.unity3d.com/ScriptReference/Object.Instantiate.html
Answer by maartenvoort · Sep 06, 2017 at 05:12 PM
EDIT: Someone mentioned i should explain it a bit better
I made objects, positioned them (without looking at x or y positioning, just dragged them and it looked good). These objects I had to put into another object (a parent) to create my prefab.
Now comes te problem, my parent is positioned at 0.04 for this prefab, but I made more and other parents are positioned between 0-2.
Now when I load in on the screen at 0,0 it is misplaced . Is there any way to place all those objects together down on the y axis instead of all apart.
Your answer
Follow this Question
Related Questions
Create with code 2.2 pizza not shooting 1 Answer
Mark gameobject field as changed from prefab 2 Answers
How to tell at runtime if a GameObject is a prefab 3 Answers
Add prefabs from a folder to array as GameObject 2 Answers
Reinitialize prefab 0 Answers