Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
splinecontroller initial position only applied after clamp.
#1
Im spawning and reusing dummy prefabs to move stuff along a spline. But their starting point should vary. When setting the initial position nothing happens when I run, the value isn't applied until the clamp happens ( which is set to loop ).

Code:
SplineController sc = a.GetComponent<SplineController>();

 sc.Position =  sc.InitialPosition = sc.Spline.GetNearestPointTF(StartPoint.position) * sc.Spline.Length;

Any idea what im doing wrong?
Reply
#2
Ensure that AutoPlay isn't enabled and set InitialPosition first, then call Play(). That should do the trick...
Reply
#3
(07-13-2016, 07:06 PM)Jake Wrote: Ensure that AutoPlay isn't enabled and set InitialPosition first, then call Play(). That should do the trick...

Thanks Jake,

I tried that just now but don't move. It looks like the moment I instantiate my objects they don't apply most of the things I call. Play() doesn't actually make my object move nor does it set the initial position.

Edit:

Fixed it by doing the following:

Code:
   
if (!sc.IsInitialized)
  sc.Prepare();
   sc.Position =  sc.InitialPosition = sc.Spline.GetNearestPointTF(StartPoint.position) * sc.Spline.Length;

I still have to put auto play to true. Calling Play() doesn't work. But in my case that's fine I need them to move anyways. But any reason why Play() might not work?
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  Convert position of a point on a spline to another spline which is connected ATHellboy 5 396 02-17-2020, 12:17 PM
Last Post: _Aka_
  Facade class which inherits SplineController ATHellboy 1 218 01-30-2020, 10:13 AM
Last Post: _Aka_
  make "GetCurrentControlPoint" in SplineController more accessable VampirasuGameStudio 1 287 01-08-2020, 11:12 PM
Last Post: _Aka_
  SplineController Delta after instantiate(Bug?) Marc Mitchell 5 940 11-26-2019, 08:38 PM
Last Post: _Aka_

Forum Jump: