03-29-2021, 09:20 AM
Hi
I will assess in the future if such a modification of the API is worth it. Independently, you can add this extension method to a static class in a file outside of Curvy's folder.
Putting this in a different file have the advantage of not having it modified or interfered with when updating Curvy Splines
I will assess in the future if such a modification of the API is worth it. Independently, you can add this extension method to a static class in a file outside of Curvy's folder.
Code:
public static void TeleportTo2(this CurvyController curvyController, float newPosition)
{
float distance = Mathf.Abs(curvyController.Position - newPosition);
MovementDirection direction = curvyController.Position < newPosition
? MovementDirection.Forward
: MovementDirection.Backward;
#if CURVY_SANITY_CHECKS
Assert.IsTrue(distance >= 0);
#endif
if(curvyController.PlayState != CurvyControllerState.Playing)
DTLog.LogError("[Curvy] Calling TeleportBy on a controller that is stopped. Please make the controller play first");
float preWrapSpeed = curvyController.Speed;
//MovementDirection preWrapDirection = curvyController.MovementDirection;
const float timeFraction = 1000;
curvyController.Speed = Mathf.Abs(distance) * timeFraction;
curvyController.MovementDirection = direction;
curvyController.ApplyDeltaTime(1 / timeFraction);
curvyController.Speed = preWrapSpeed;
//MovementDirection = preWrapDirection;
}
Putting this in a different file have the advantage of not having it modified or interfered with when updating Curvy Splines
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Available for freelance work—feel free to reach out.