When projecting on a closed spline, the SplineProjector is set to handle triggers without detecting any looping/wrapping. This causes all triggers to execute, as the percent jumps from near 0 to near 1 (or vice versa).
Changes
I added a wrapCutoff variable to the SplineProjector which becomes visible in the Inspector when Loop Samples is turned on. This value determines when the code should detect a jump, since there's no perfect way of detecting this. It depends on framerate, spline shape, projector positions and projection results. The Discord thread includes some images that may explain this variable better.
Tests available on test branch
Issue
See Discord thread
When projecting on a closed spline, the SplineProjector is set to handle triggers without detecting any looping/wrapping. This causes all triggers to execute, as the percent jumps from near 0 to near 1 (or vice versa).
Changes
I added a
wrapCutoff
variable to the SplineProjector which becomes visible in the Inspector whenLoop Samples
is turned on. This value determines when the code should detect a jump, since there's no perfect way of detecting this. It depends on framerate, spline shape, projector positions and projection results. The Discord thread includes some images that may explain this variable better. Tests available on test branchNotes
The following lines handle two things for when the samples are looped: the events and trigger/node checks. https://github.com/Dreamteck/splines/blob/df098d348c304dbbde6b255f61e00e1940a70b63/Assets/Dreamteck/Splines/Components/SplineProjector.cs#L211-L236 However, the trigger/node checks should occur even when there is no event listener. Secondly, the events should trigger even if the samples are not looped. In my changes, I have reworked the existing logic to separate those two. https://github.com/Kronoxis/splines/blob/2f6a7b8b7701417da849097d63b2afe57091c1c5/Assets/Dreamteck/Splines/Components/SplineProjector.cs#L228-L250 Note that the events are still only called when
loopSamples
is true. This logic may require some more rework.