02-04-2020, 08:37 PM
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
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.
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.
Available for freelance work—feel free to reach out.