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


Possibly Related Threads…
Thread Author Replies Views Last Post
  Add noise to spline controller movement DekoGames 2 10 02-06-2024, 01:28 PM
Last Post: DekoGames
Question Setting instantiated object to spline, then starting movement? _RicO 3 9 06-28-2023, 06:01 PM
Last Post: _Aka_
  How do I make the computer ignore it's parent transform? eastes 3 7 04-06-2022, 12:16 PM
Last Post: _Aka_
  Connect knots to transform BanksySan 3 1,181 01-11-2021, 08:06 AM
Last Post: _Aka_

Forum Jump: