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
  Generating multiple object on changing transform jawadkhan.9026 12 2,916 09-06-2019, 09:39 PM
Last Post: _Aka_
  Choppy movement Lasercat69 1 963 01-13-2019, 10:54 AM
Last Post: _Aka_
  Problem with backward loop movement Szagi 4 1,984 11-23-2018, 02:58 PM
Last Post: _Aka_
  Wrong movement between splines Sergei543071 3 2,042 07-30-2018, 12:17 AM
Last Post: _Aka_

Forum Jump: