Hey, I have a vector math question that I am struggling to find an answer too. Unfortunately Chat GPT was unable to help me, so here I am…
I am looking to create a snapping tool for a little in-game editor I am working on for my game. This is done in UE4.27, although i’m sure the solution is the same in any version of unreal.
I want to use a location, rotation and a grid spacing float variable to create a custom coordinate system. I then want to allow players to snap objects to the closest whole number point of that system.
To make things a little more complex I also have the ability to multi-select objects, and wish for a group of selected objects to also be snapped to this custom coordinate system. The group would use the bounding centre of all objects as the point that would need to match the whole grid coordinate, and the objects would maintain their position relative to each other as they were prior to the snap.
This is the little actor I made to represent the object that a player can place down and use as custom coordinates. As seen in the image, the actor can be placed as various angles also, so this would need to be accounted for (hence my mentioning location AND rotation earlier).
The above image is my final attempt with help from GPT, but it doesn’t work. This attempt also just uses a single actor, instead of a group, since my previous attempts at working with a group were unsuccessful, I wanted to see if I could get a single object working.
The Function initially checks for the existence of the grid object, and if it does not exist, it will simply use the unreal global coordinate system (i.e. it will use 0,0,0 for location and rotation inputs of the function).
Hopefully I have done a good job at explaining the desired outcome, and I would really appreciate anyone who may have some insight into my problem!
Thanks for taking the time to read!