Hello, everyone. I am currently developing a turn-based strategy and one of the core ideas in my game is that it is played on the surfaces of a cube.
the following figure shows one of my pawns sitting on a corner space of the cube with 4 possible movements he can take highlighted in green.
the goal is that when one of the spaces is selected the unit will move to the new space and orient itself correctly based off of the direction it was moving.
currently the character will move to a new space fine, but Its orientation is not correct.
I’ve tried just getting a look at rotation from the location of the old space and the location of the new space. This works for the spaces on the same side of the cube, but it gives some wonky angled rotations when switching surfaces.
I am having trouble coming up with a method that will work on every surface of the cube due to the fact that you will be dealing with different axis’ on each surface.
if you have any ideas please let me know. i’m very stuck!
as you can see in the GIF i got it to work! I started messing around with each of the “Make Rot from” nodes just to experiment with what happens.
The Make Rot from Z like was used in @Orkney’s link (https://blueprintue.com/render/e4k6ss2e) provided really good results. With it i was able to get my unit’s feet to always be on the space no matter which side of the cube it was on. At that point i knew i needed to make a Rot from Z so i started to experiment with “Make Rot from ZX” and “Make Rot from ZY”.
When experimenting with ZX I decided to get the Unit Direction Vector from the location of the character on the old space to the location of the new space. I plugged the normal of the line trace into Z and the unit direction vector into X and got my Rotation. It works perfectly!
Here is the Blueprint for anyone else that may run into something similar later on.
The Vector math is still a little bit confusing to me. if someone would be willing to go into some detail on what is exactly happening that causes this to work I would be happy to include it in my original post so that maybe it will help anyone else that is running into a similar issue.