Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Moving Platform
#7
Hi,
Found the cause of your issue. It is unrelated to Curvy Splines.

Your issue is that you compute the velocity from previous frame, and apply it to your capsule on the current frame. So you will have a delay. This delay, when the platform reaches the end of the spline and comes back, is translated as a "jitter" between the platform and the capsule.

Here is a fixed version of your code:

Code:
using FluffyUnderware.Curvy.Controllers;
using UnityEngine;

public class TestSplinePlatform : MonoBehaviour
{
    public Rigidbody rb;

    public SplineMovingPlatform splinePlatform;

    private void FixedUpdate()
    {
        Vector3 platformVelocity = GetPlatformVelocity();
        rb.velocity = platformVelocity;
    }

    private Vector3 GetPlatformVelocity()
    {
        float speed;
        {
            speed = splinePlatform.controller.Speed;
            if (splinePlatform.controller.MovementDirection == MovementDirection.Backward)
                speed *= -1;
        }

        return splinePlatform.controller.Spline.GetTangent(splinePlatform.controller.RelativePosition) * speed;
    }
}


Important point, make sure your script executes before the spline controller. (see Project Settings -> Script Execution Order).

If and when you feel like it, please leave a review for the asset, that helps a lot.
Have a nice day
Please consider leaving a review for Curvy Splines, this helps immensely. Thank you.
Reply


Messages In This Thread
Moving Platform - by Kokoriko49 - 09-06-2024, 04:48 PM
RE: Moving Platform - by _Aka_ - 09-07-2024, 02:41 PM
RE: Moving Platform - by Kokoriko49 - 09-10-2024, 03:55 PM
RE: Moving Platform - by _Aka_ - 09-11-2024, 09:23 AM
RE: Moving Platform - by Kokoriko49 - 09-19-2024, 09:51 AM
RE: Moving Platform - by _Aka_ - 09-20-2024, 07:54 AM
RE: Moving Platform - by _Aka_ - 09-20-2024, 04:20 PM
RE: Moving Platform - by Kokoriko49 - 09-22-2024, 08:27 AM
RE: Moving Platform - by _Aka_ - 09-23-2024, 09:20 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Moving object down or up the spline using gravity velikizlivuk 6 4,070 07-26-2023, 10:06 PM
Last Post: _Aka_
  how to make fast moving controller go all the way to linear points?(curvy8) hawken 7 4,930 06-06-2023, 09:47 AM
Last Post: _Aka_
  Obstacle Moving Along the spline Chanon 1 1,812 06-13-2022, 04:13 PM
Last Post: _Aka_
  Possible to jump from platform to platform with Curvy splines? yun844 1 1,608 01-04-2022, 11:47 AM
Last Post: _Aka_

Forum Jump: