I am currently trying to have players be able to make sloped surfaces using splines, however, i cannot seem to understand how to have the tangents be rotated with the spline points. Im sure its some super complicated math. I noticed that if you rotate a spline point in the engine, it rotates the tangents with it, but why does it not do that on runtime?
The tangents don’t follow because they’re stored in the spline point’s own space and you’re probably only changing the point’s rotation, not the tangent vectors. In the editor the spline component rotates the tangent handles for you; at runtime you have to do it yourself.
Use “Set Spline Point Type” / “Set Tangents at Spline Point” (or “Set Location/Tangent at Spline Point”) and compute the tangents from the new rotation. For example, with Coordinate Space set to Local, take the old tangent and rotate it by the delta: RotateVector(OldTangent, DeltaRotation), then set it for both Arrive and Leave tangent (Set Tangents at Spline Point takes both, or use Set Arrive/Leave Tangent separately).
A more robust way for sloped surfaces is to skip manual rotation: set the point type to “Curve Clamped” or “Curve Custom Tangent”, set only locations with “Set Location at Spline Point” (Update Spline = false while looping), and call “Update Spline” once at the end so the tangents are regenerated from the new positions. If you need the tangent length to match the neighbouring point distance, use Length = Distance(PointA, PointB) and Direction = GetForwardVector(rotation) * Length.
Also check you’re using the same Coordinate Space (Local vs World) when reading and writing, since mixing them is the usual reason tangents look unrotated.
I Tried this and it appears to work so far, but I want to be absolutely sure before marking this as the solution. Thank you for your help!
While it appears it is working to some extent, it seems to only rotate in one direction, it is very unfriendly and is kinda making me aggravated. I really badly wanted to let players make the slopes they wanted, but this is starting to become so aggravating to work on that I am starting to think about just making it set pieces.
The one-direction result is the tangent direction, not the slope being impossible.
In Unreal, Arrive and Leave on the same point both point along the direction of travel. They are not opposite Bezier handles. If you negate one of them (Arrive = -Forward * length, Leave = +Forward * length), the point only bends cleanly one way and kinks the other. Set both to the same vector.
Don’t Rotate Vector a tangent you already wrote, either. That compounds, so it feels right in one direction and wrong as soon as the drag reverses. Keep a base length (distance to the neighbor, or a fixed handle length) and write the absolute direction every time:
- Set the point type to Curve Custom Tangent first. Curve Auto and Curve Clamped overwrite your tangents on the next Update Spline, which looks like only one side stuck.
- Dir = Get Forward Vector(DesiredRotation). Pitch is in that vector, so up and down both work. Len = distance to the next point.
- Set Arrive Tangent at Spline Point (Dir * Len, Local) and Set Leave Tangent at Spline Point (Dir * Len, Local).
- Set Rotation at Spline Point (DesiredRotation, Local) as well, so the mesh up-vector matches the slope. Then Update Spline once.
Use the rotation you meant to apply, not Get Rotation at Spline Point. The sampled rotation is derived from the current tangents, so feeding it back fights you and pitch only seems to work while the tangent already agreed with it.
Keep the same coordinate space on the read and the write (Local). Mixing World and Local is the other way to get a slope that only tracks yaw.