Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rigidbody or Transform Movement
#11
Hi,

I think that in your case it's better to start from a blank slate instead of overriding from a controller. This way you will have to handle a small code base, since the controllers have code for features that you don't use and that code makes it hard for you to implement new features.

Here is a simple follower's code
Code:
using FluffyUnderware.Curvy;
using UnityEngine;

public class SplineFollower : MonoBehaviour
{
   public CurvySpline Spline;

   [Range(0,100)]
   public float Percentage;

   void Update()
   {
       float distance = Spline.Length * Percentage / 100f;
       float tf = Spline.DistanceToTF(distance);
       transform.position = Spline.transform.TransformPoint(Spline.Interpolate(tf));
       transform.rotation = Quaternion.LookRotation(
           Spline.transform.TransformVector(Spline.GetTangent(tf)),
           Spline.transform.TransformVector(Spline.GetOrientationUpFast(tf))
               );
   }
}

Set its spline, and modify Percentage to see the object follow the spline.

If you have the knowledge to make an object move and jump on flat platforms (mario bros style for example), you should be able to do so on on curved splines by integrating the relevant parts of this code into yours.

If you don't know how to make an object move an jump on flat platforms, you can take a look at various example projects and open source projects out there. No need for it to be Unity based. The important thing is for you to understand the logic behinds it.

I hope this helped you.
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Smile Simple splines movement shills 3 266 02-26-2025, 09:40 AM
Last Post: _Aka_
  Left-right movement, and spline follow shihaya 3 166 07-12-2024, 12:50 PM
Last Post: _Aka_
Question VolumeController CrossRelativePosition Very Choppy Movement pako88 5 286 06-07-2024, 03:43 PM
Last Post: _Aka_
  Add noise to spline controller movement DekoGames 2 151 02-06-2024, 01:28 PM
Last Post: DekoGames

Forum Jump: