Hi guys,
In my C# project, I have a series of racers. I have a spline for each racer, and each racer progresses along this at a rate determined by an Animation Curve (acceleration is determined by evaluating the curve over time). This means no pre-existing animations are needed.
I am trying to port this for use with Needle engine, however I am struggling as Needle doesnt expose a series of functions used in these Unity spline classes such as EvaluatePosition(), EvaluateTangent(), EvaluateUpVector() from the SplineUtility.cs script, which in turn uses other functions in the SplineUtility and the CurveUtility class.
I looked at the spline example in the samples, and am not really understanding its use as it all seems based on pre-defined animations, which is the complete opposite use case of what I want to use it for.
Iβve included my C# code to show what I am trying to recreate.
private System.Collections.IEnumerator SimulationRoutine(IReadOnlyList<Participant> participants)
{
float elapsed = 0f;
while (elapsed < m_ParticipantConfig.CompletionTimeMax)
{
elapsed += Time.deltaTime;
foreach (var participant in participants)
{
Spline spline = participant.Spline;
GameObject runner = participant.Target;
float completion = participant.CompletionTime;
float progress = Mathf.Clamp01(elapsed / completion);
Vector3 position = spline.EvaluatePosition(m_ParticipantConfig.AccelerationCurve.Evaluate(progress));
runner.transform.position = participant.PathOffset + position;
var remappedForward = Vector3.forward;
var remappedUp = Vector3.up;
var axisRemapRotation = Quaternion.Inverse(Quaternion.LookRotation(remappedForward, remappedUp));
var forward = Vector3.Normalize(spline.EvaluateTangent(progress));
var up = spline.EvaluateUpVector(progress);
runner.transform.rotation = Quaternion.LookRotation(forward, up) * axisRemapRotation;;
}
yield return 0;
}
}
Any nudge in the right direction is appreciated.