- Home /
Transforming and center points don't line up.
// This chooses which room to use. int num = 2; if (amountofrooms < 10) { int temp = Random.Range(1, 8); switch (temp) { case 1: num = 2; break; case 2: num = 3; break; case 3: num = 4; break; case 4: num = 6; break; case 5: num = 9; break; case 6: num = 11; break; case 7: num = 13; break; } } GameObject ins = Instantiate(rh.Rooms[num], new Vector3(-9.6f * 2 + this.transform.position.x, this.transform.position.y, 0), Quaternion.identity);
So I am trying to make a dungeon game where the dungeon is random every time. The problem is that when spawning all the rooms which are in prefabs they wont always match up ie floors wont be on the same x axis. When looking at what could be the problem I tried lots of things and found it odd that they are able to go onto of each other and are the same size and center point but when I zero them out they end up in different positions. Is there some way to fix this?
no one can help you correct your code or give suggestion without seeing your code. you got to post your script so we can see what you are talking about and where you are going wrong
Right, also if multiple different prefabs are used it highly depends on how they actually look like and if they actually have the same pivots. $$anonymous$$eep in $$anonymous$$d that you have to switch the gizmo mode to pivot in the editor, not center. The center mode might be misleading. The object pivot is the actual position of an object. The center mode has no effect for code. It's just a setting of the sceneview in the editor.
Answer by maxwellalltheway · Mar 23, 2019 at 02:44 PM
Thanks for the help, I figured out a way to create my own pivot points and it works perfectly. https://www.youtube.com/watch?v=itIh8PYGP7w this video shows how to create a pivot point using a empty gameobject.
Your answer
![](https://koobas.hobune.stream/wayback/20220612194113im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to center prefabs' children to (0, 0, 0) without changing their position relative to each other 1 Answer
Unity 4 art prefabs not working in Unity 5. 1 Answer
Moving a GameObject to a certain point in world space via script 1 Answer
Spawning objects around a point 1 Answer
How do i move a GameObject to the same height as another GameObject? 0 Answers