- Home /
How to stack Prefabs in the scene dragged from Project List
Hi,
For a Level Editor which works at Runtime, I want to drag and Instantiate Prefabs from the Editor-Project-List into the Scene. While being dragged they should stack on the surface of existing instantiated objects in the scene view.
The Problem is that the prefabs - while being dragged - are overlapping other objects in the middle. What I basically need is Auto-Surface Snapping of a instantiated object and a Prefab which is dragged nearby. By the way, IsKinematic is turned on, so Objects do not react to Physics during Editing.
I attached screenshots for clarification. Picture 1 shows the behaviour I experience and Picture 2 shows what I want to achieve during dragging a second cube prefab into scene from my Project List. Any suggestions how to make sure Objects are not overlapping in this scenario?
Greets -act
Put a box collider on the cube so they can't overlap. As for the snapping you could use $$anonymous$$athf.Round for the positions of the cube so they will always have a whole number as the position. Hope I could help
Thanks for the comment. There are box colliders on the cubes, but which don't work while iskinematic is turned on. On the one hand, I need the snapping, on the other hand, I don't want the objects react to physics as this would obviously mess up the level design process.
Box collider's should work even if the object is$$anonymous$$inematic.
is$$anonymous$$inematic can affect box colliders in certain situations. Anyway, are you dragging them in while the game is running? Thats what it sounds like (I dont have an answer for that) if you mean in Edit $$anonymous$$ode, what you can do is Drag the new prefab onto the previous prefab in the Hierchy (to the point where the name of the old prefab is Completely highlighted) then change the x y and z position values to 0 (it will be the exact same position of the first prefab) then change the value of the y position in the inspector to 1 or 2 or however big the distance is between them). Then, in the Hierchy, drag the second prefab off the first prefab (so that ins$$anonymous$$d of highlighting the name of the prefab it is a blue line with a dot right underneath the name of the first prefab) that way they will appear in the hierchy in the order that you place them.
Hi there - yes my Level Editor works in Play()-$$anonymous$$ode. Strange thing is that I believe that the behaviour once was working as intended. Anyways, what came to my $$anonymous$$d and what I try next week is to check collision between a placed object and a dragged object and calculate a appropriate Y-Value offset to be added to the dragged object at time of collision. This may do the trick.
Your answer
![](https://koobas.hobune.stream/wayback/20220611231559im_/https://answers.unity.com/themes/thub/images/avi.jpg)