Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
LODs
#11
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.

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 will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply


Messages In This Thread
LODs - by digot - 03-20-2021, 07:41 PM
RE: LODs - by _Aka_ - 03-21-2021, 07:06 PM
RE: LODs - by digot - 03-21-2021, 07:59 PM
RE: LODs - by _Aka_ - 03-22-2021, 09:19 AM
RE: LODs - by digot - 03-22-2021, 01:21 PM
RE: LODs - by _Aka_ - 03-22-2021, 05:27 PM
RE: LODs - by digot - 03-23-2021, 02:59 PM
RE: LODs - by _Aka_ - 03-26-2021, 08:35 PM
RE: LODs - by _Aka_ - 03-25-2021, 05:28 PM
RE: LODs - by digot - 03-28-2021, 03:52 AM
RE: LODs - by _Aka_ - 03-29-2021, 09:20 AM
RE: LODs - by digot - 04-04-2021, 01:49 AM

Forum Jump: