Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how do I position a splineController on a spline in runtime to an exact position?
#8
(01-18-2018, 02:41 PM)_Aka_ Wrote:
(01-18-2018, 04:19 AM)hawken Wrote: Thanks I changed to a relative position and went from there, works nicely however in the end I had to make it a coroutine and do a while loop to make it / force it to go to the place I wanted, seems sometimes spline controllers go to 0... took about 5~10 frames before it went to the correct position.


This seems overly complicated.
Here is a simple way to do the switch:
Code:
if (splineController.Spline == Spline1)
    splineController.Spline = Spline2;
else
    splineController.Spline = Spline1;

splineController.RelativePosition = 0.5f;

//Uncomment this if your splineController has PlayAutomatically set to false
//splineController.Play();

I also attached a scene with this code in a script. You just have to click or press any button in playmode to operate the switch

thanks for this, I'm generating "myPath" in run time from 3 other paths, I wait until it's initialised then run that script. It works fine the first time I make my SC jump to it, but for some reason if I repeat the process it always defaults to position 0 for a few frames then by brute force I keep trying to move it to the requested position. I'm guessing the new spline that is generated isn't initialised.
Reply


Messages In This Thread
RE: how do I position a splineController on a spline in runtime to an exact position? - by hawken - 01-19-2018, 06:26 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Set Volume to the Volume Controller at Runtime pako88 2 10 04-08-2024, 03:26 PM
Last Post: _Aka_
  Curvy Line Renderer for UI Spline? gekido 3 6 04-04-2024, 12:56 PM
Last Post: _Aka_
  Get position of all control points for a spline gekido 1 6 03-28-2024, 10:08 PM
Last Post: _Aka_
Bug Changing spline connection in inspector causes splines to revert to defaults lacota 3 6 03-18-2024, 07:55 PM
Last Post: _Aka_

Forum Jump: