Download

Getting new position based on former postion

Hello,

I’m trying to create a blueprint where I spawn static meshes along a certain axis, but allow the user to rotate the meshes. However, when a mesh is rotated, the new mesh follows the new direction from the previously rotated mesh. The problem I have is getting the new position. Is there an easy way to do this?

For instance, if my cube is spawned at 0,0,0 and the spacing for the next one is 10,0,0 but that mesh is rotated 45 degrees. The third spawned mesh would not be at 20,0,0 but something like 15,5,0. How do I determine that position?

Below, R is the distance from the axis of the object to the predetermined spacing value. If I was going in 1 direction, X would always be the same. However, once I rotate it, X becomes less and Y begins to get a value based on that.

3f77c3b0ebb4f7dfe35c6ac3e46ad3dc0509841d.png

If I understand you correctly you want to have the same distance between cubes. Such distance can be represented as a circle, where each point on the circle is where new cube can be placed.
Without doing any complicated math, position on a circle of given radius can be found simply by making a vector from current point to some other arbitrary point in space (mouse cursor on screen, axis vector of object, position of another object). Then you just normalize this vector and multiply result by a radius which you need.