Adjusting Climb Transforms

The first change I made was to add an offset variable for the z-axis so that the player’s hands align with the spline. Then, my second change was an attempt to make the player face towards the spline. However, in my effort to align the player’s rotation, I unintentionally caused the player to rotate uncontrollably. I tried setting the correct rotation of the player at the spline location through C++, but that did not resolve the issue. Next, I explored the spline’s forward vector, but it only pointed in one direction with respect to the overall Actor. I also examined the right vector at the spline distance, but it resulted in spinning along the spline. Furthermore, I tried using the spline’s tangent and the world up vector to determine the direction using cross product math. Unfortunately, that approach yielded similar behavior. Ultimately, I began to believe that the vectors from the spline were highly unreliable, as they did not consistently provide the direction I was seeking.


Instead of trying to do that, I made the decision to revisit the construction script for BP_Spline and incorporate the creation of an arrow component that faces the desired direction for the player’s new forward direction. This can be seen in the photo above. The next step involved obtaining the correct vector that the player needs to rotate towards based on this adjustment.

What I attempted to do was to utilize similar calculations that were used for the arrow components. I tried to obtain the vector between the player’s location on the spline and the spline point, and then derive the rotation from the z-axis. Unfortunately, this approach proved to be flawed as well.

Then, I had the realization that I could UE_LOG the right vector at the location along the spline to observe its values. I noticed that the values were adjusting appropriately. Lastly, I concluded that the solution would involve setting the z-axis value of the right vector to 0.0f and then inverting it to obtain the new forward vector for the player. The code solution can be seen above.

The above video shows the final result of these changes.

What’s Next?

Next, I will update the animation montage to include sections that correspond to the movement enumerations. This will allow us to switch between different animations when climbing or transitioning on the spline graph.