I’m having trouble aligning these snapping cubes. Does anyone know if there are nodes in BP that help with stuff like this? Does anyone know an equation that will help?
Any discussion on how to start to attempt to solve this would be awesome!!
vid of my problem: Notice the gap when the cubes snap together. Also notice the attaching orientation of the axis. In this case the Z axis has to align to the X axis.
This is something I came up with without giving much thought on efficiency, but if you run this logic only once when snapping, I don’t think it will matter a lot.
What you can do is, since you know Up, Right and Forward for each object, you can multiply each by -1 to get the opposite vectors (i.e. Down, Left and Backward). With 6 axes, when snapping, you can calculate the snapping orientation of the object by getting the forward vector of the cube and calculating which of the 6 axes is closest to the forward vector of the other cube and then making that axes the forward vector of the other cube. Repeat this with the Up or Right vector and either do this again with the last local axis or calculate it using cross product of the first two calculate axes.
About the gap, that looks to me that that is an orientation alignment issue and not a location one. If it is a location one, I would have an Overlapping event used with Sweep to calculate the normal at which the object was overlapped and use that normal to set the overlapping object at a position (pivot point of cube + [ normal * length of cube ]). I am assuming here that the length will be the same for all sides, since it is a cube, right? I also assume that the pivot of the cube is at the center.
There might be a more efficient way of doing this, but I think this is a good way to start.
Let me know how it goes!
Hey! Thanks for you answer. It was a orientation issue. I was able to solve it by rounding the rotator to the nearest 90deg.
Solved by Rounding the Rotator to the nearest 90deg.
Does this work when you are trying to align the cubes when the Target cube is not at a 90 degree rotation (e.g. Yaw 30)?
in worldspace, No… in localspace yes. my base cube will always be at 90. (in my game)
I am working on the worldspace issue now. It should just be a matter of rounding to the orientation of the base cube…i think. I posted a vid link.