# How to properly orient instances along corner edges

I'm currently trying to create simple level geometry for a game I'm working on. I've seen people use cubes with extrusions and then overlay those meshes with bricks and tiles to quickly create buildings.

I've already looked into it and this is what I have right now:

As you can see, it isn't quite working as planned.

The way I achieve this is by checking the angles and direction of the edges to see what is horizontal vs vertical. Then turn the mesh into curves and using them to create mesh or place instances along those curves.

The main issue I have right now is that the instances I place on the cornes are not aligned properly and I have a hard time finding a solution for this. I've looked at some tutorials about aligning instances to normals, but it doesn't quite work in this specific scenario. This is what I have right now:

The whole Transfer Attribute > Align Euler To Vector just doesn't give the right result, even with different combinations.

So my question is: How do I get the right orientation for the instances on the corners?

I'm also very new to Geometry Nodes and especially new to what I'm trying to create right now, so tips and tricks are very welcome also.

• if u provide blend file i will try to find a solution...but i am too lazy to rebuild your setup... Commented May 8, 2022 at 10:03
• I added the .blend file to the question. Commented May 8, 2022 at 12:22

Basically, it is only a matter of deciding on a certain direction for a rotation, according to which the stones are then aligned.

I would solve it like this:

1. First get the normals of the faces and form the cross product with the up vector. This will move the vertices all in a certain direction.

2. If you form from these directions again the cross product with the X-axis and the Y-axis, you get further directions with which you can work.

3. From the directions created before you can then, with a little logic, calculate a precise direction that runs along a wall.

4. Finally, you use this direction, in conjunction with the rotation resulting from the node Curve to Points, with the node Align Euler to Vector and pass the resulting value to your instances.

Note that the center of the objects to be instantiated is also important.

Here is the relevant group at a glance:

And here is the blend file:

• wow, this is a bunch of vector math. Looks nice. +1 Commented May 8, 2022 at 22:52
• This is indeed what I was looking for! I'm interested in how it works. I did notice that it sometimes swaps back to the old orientation, even with straight edges Commented May 9, 2022 at 10:46
• @RensPitman Updated the nodes, now it works as expected ;-) Commented May 9, 2022 at 14:07