Hello. I am attempting to create a custom AI for ships so that they can navigate around obstacles using a Nav Mesh. I am using a spline system where a path is generated asynchronously, path points are then taken and used to generate a spline with the Start Point being the ships origin and the end point the destination, and then a tangent is calculated using “Find Tangent to Closest World Location” function in order to calculate the Yaw required to follow the path. The path is generated per tick so the Start Point is always updated to the ship’s origin. This tangent is then used to calculate a difference between that Yaw and the Ship’s Yaw via a Delta Rotator with values clamped in range between [-90, 90] and [-1, 1] and a command is given to turn based on the output.
This method works but runs into a hiccup. The ships will properly orientate themselves to the desired tangent point but it seems that at certain positions in the world (large grid sections) the ships will begin to spiral and continuously turn in 1 direction. Inspecting the Blueprints with print texts nodes, in certain instances the Delta rotator will “flip” and what seems to happen is that what would be for say a Delta of 5 Degrees is then expressed as -175 Degrees. This goofs the clamp in range where yes I am in reality only 5 Degrees off the tangent, yet the ship believes it is 175 degrees off and will proceed to spiral in one direction as the clamp output becomes -1 (some research yields this is an issue with Quaternions but I am unsure).
It is my belief that the “Find Tangent Closet to World Location” can give 2 tangent vectors with the only difference being the magnitude of their vectors being inverted. The slope has not changed but the direction and therefore my Delta calculation takes it wrong. I am looking for a possible solution to this on how to combat it or if I am totally wrong about my hypothesis a different explanation perhaps and how I may approach this. Thank you in advance.