19/01/23 - World to local coordinate translation


After some research, I have found a node that I can use to translate coordinates from world space to local, this has proven to be incredibly useful as I am able to ensure that my mechanics can work regardless of their placement on the axis or rotation. I have made changes to my mechanics wherever necessary as of yesterday.

The two mechanics this is especially useful for are the painting tool and the actuators (levers buttons sliders). Due to how I had previously programmed them, they only worked on specific axes. After rotating the lever to a different axis for example, it would no longer work; this was due to the lever using a specific axis coordinate of the players motion controller to check the positioning relative to the lever. In order to get the lever to work horizontally, I originally had to create a check at the begin play event node which would take the levers world rotation to check whether it was vertical or horizontal, this was stored in a bool which was later used to determine whether to use the motion controllers x or z coordinate. This took up a lot of space with many nodes. If I were to allow the lever to be used on any axis I would have to add checks to take the y axis into account as well as whether the inputs should be flipped. This would take a lot of effort with many more duplicate nodes and likely the need for a switch statement.

Using the translation node completely negated the need for this as when an actor is rotated, its local axis are rotated as well; this meant the axis in line with the lever or slider would remain the same so the relative position of the players motion controller would remain consistent.

By modifying my current code to make use of this node I was able to remove the vertical bool that I initially used to track the position of the lever. The levers and sliders can now be used at any rotation or scale without modification.

For the painting tool, it allowed me to create more painting canvases that weren't locked to a specific axis. It also made it viable for canvases of different scales. This can be shown in both the clipboard and the letter used for opening the door. These objects are held by the player and their rotation consistently changes, furthermore it is not locked to a specific axis. Without this node, I would not have the knowledge on how to map the motion controllers coordinates to the painting canvas as unlike the levers, the base section is not locked to a canvas and is constantly moving, my original code for adapting to the levers rotation was calculated at begin play, so it could not be rotated later without breaking the code.

Without the translation node, placing a draw canvas on both the letter and the clipboard would be impossible.

Leave a comment

Log in with itch.io to leave a comment.