Hi guys
I’ve got a circle spline (not closed) of 4 points and based of a mesh density int varaible I do the math and I’ve got an equal amount of distance along the spline where I add my spline meshes
from this distance I use get location and tangent at distance
location looks correct but the tangent looks off like it’s not follow the spline but more a default tanget , is anything i miss?
yeah this one bites everyone. get tangent at distance along spline reads the segment interpolation, not the point handles, so with 4 open points the first few samples look right and then it drifts once the subdivided segments bend away from the point tangents.
thing to check first is point type. if the points are set to linear or constant the tangents at distance are basically defaults between kinks. set all four to curve, call update spline once after any move, and read with coordinate space set to world so you are not mixing local tangents with world placement.
if the mesh orientation still wobbles at 8 and 12, drop a debug arrow at each sample using the returned tangent and compare against get direction at distance along spline. when those two disagree the spline needs more points or reparameterization, its usually not your math.
The tangent you get from Get Tangent at Distance Along Spline is not a unit direction. It is the spline’s derivative, so its length depends on how long the spline segment is. A Spline Mesh Component wants Start/End Tangent scaled to the length of the mesh piece you are stretching, which is why 4 pieces look right and 12 pieces start to wiggle: the tangents are far too long for each short piece and the curve overshoots.
Try this per piece i, with Step = SplineLength / Count:
Start Pos = Get Location at Distance Along Spline (i * Step), Coordinate Space = Local.
End Pos = same node at ((i+1) * Step).
Start Tangent = Get Direction at Distance Along Spline (i * Step) (normalized, Local), multiplied by Step.
End Tangent = Get Direction at ((i+1) * Step), multiplied by Step.
Call Set Start and End on the Spline Mesh Component with those four vectors.
Use the same Coordinate Space everywhere. If the spline mesh components are attached to the actor, Local is correct. Also set Forward Axis on the Spline Mesh Component to match your mesh’s long axis (usually X).