Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Setting speed manually
#2
Sounds like you should most likely just create your own Controller:
- it can be based on the existing SplineController
- or if you want to use physics and move your target object by forces, you could also do something like "RigidBodySplineController.cs" (which you can find under Assets\Packages\Curvy Examples\Scripts\RigidBodySplineController.cs).

You can then control the "speed" anyway you want.

Basically, if you understand how some important methods work you can just create a Controller of your own easily.
I'll give you an example here:

Code:
public int speed = 10;
public CurvySpline spline;

private float TFv = 0f; // this represents where you are on the spline (range 0..1)

void Update()
{
 if(TFv < 1f)
 {
   TFv += speed * Time.deltaTime; // go further on the spline using the "speed"
   Vector3 worldPoint = spline.InterpolateFast(TFv); // get the actual world point from the spline that corresponds to the total fragment value (TFv)
   Vector3 fwd = spline.GetTangentFast(TFv); // you get the orientation so you can maybe set the transform.forward you want to "fwd"

   transform.position = worldPoint;
   transform.forward = fwd;
 }
}

This is not tested, just an "idea".
Hope it helps.
Reply


Messages In This Thread
Setting speed manually - by BigYetti - 12-04-2015, 03:13 AM
RE: Setting speed manually - by ioanma - 12-04-2015, 05:20 PM
RE: Setting speed manually - by Jake - 12-04-2015, 07:39 PM
RE: Setting speed manually - by BigYetti - 12-16-2015, 11:07 PM
RE: Setting speed manually - by Jake - 12-17-2015, 06:14 PM
RE: Setting speed manually - by BigYetti - 12-18-2015, 08:26 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How could I manually set the bound? Chanon 1 8 09-17-2023, 10:11 AM
Last Post: _Aka_
Question Setting instantiated object to spline, then starting movement? _RicO 3 9 06-28-2023, 06:01 PM
Last Post: _Aka_
  Manually controlling scale of each CP Maldruzard 1 5 03-27-2023, 10:58 AM
Last Post: _Aka_
  Change Speed on spline linkinballzpokemon 1 28 12-29-2021, 10:58 AM
Last Post: _Aka_

Forum Jump: