- Home /
Any easy way how to stick many blocks of prefabs one beside the other?
Hi Guys, I bought this 2D platform kid for building 2D scenes. It is great, but the size of a single blog is 2.56 on the X and Y. When putting them together I need a calculator to set them on the exact position to fit one next to the other :-)
Any better way?
Thanks
Hi, thanks a lot! Snap Settings is what I was looking for :-). Great!
Answer by KazooCar69 · Feb 05, 2015 at 05:16 PM
If the object has a renderer, you can get the size of it with renderer.bounds.size If it has a collider, you can use collider.bounds.size, both are vector3's.
Take your width and spawn your next block at the gameobject's position + it's width and it'll be right next to it. This is if you want to procedurally generate them, of course.
You can even use that in an editor script to make a snapping tool, but that'll be a bit more work.