Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Setting instantiated object to spline, then starting movement?
#1
Question 
Hi, I've been trying to go through your tutorials and documentation, but it's a little overwhelming for me trying to find how to do this.  Blush

I "draw" a spline at runtime, then instantiate an object (that already has an empty SplineController component attached). I need to find a way to Add the newly created CurvySpline to the Object's Spline Controller component then start the position "movement" of it along the spline.

This is what I tried to add the spline to the instatiated object's SplineController, but doesn't seem to work.
Code:
MyObject.GetComponent<SplineController>().Spline = MyNewSpline.GetComponent<CurvySpline>();

As for starting the animation of the object moving along the spline, and controlling it's speed, I'm really not sure where to even start.

As a bonus question, is there an easy way to get the First point's world position on a new spline? Similar to 
Code:
CurvySpline.GetNearestPoint()
Reply
#2
Hi
This API tutorial will be helpful
https://www.youtube.com/watch?v=CPOfoIVbeCE
This other one might be helpful too
https://www.youtube.com/watch?v=4Y_7l95Q4uQ
If you still have questions after that, please let me know.

To get a point, use CurvySpline.Interpolate. Here is its api reference
https://api.curvyeditor.com/FluffyUnderware.Curvy.CurvySpline.html#FluffyUnderware_Curvy_CurvySpline_Interpolate_System_Single_UnityEngine_Space_
There are other "sister" methods that might be helpful. They do have the word "Interpolate" in their name.

Did this help?
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#3
(06-22-2023, 09:26 AM)_Aka_ Wrote: Hi
This API tutorial will be helpful
https://www.youtube.com/watch?v=CPOfoIVbeCE
This other one might be helpful too
https://www.youtube.com/watch?v=4Y_7l95Q4uQ
If you still have questions after that, please let me know.

To get a point, use CurvySpline.Interpolate. Here is its api reference
https://api.curvyeditor.com/FluffyUnderware.Curvy.CurvySpline.html#FluffyUnderware_Curvy_CurvySpline_Interpolate_System_Single_UnityEngine_Space_
There are other "sister" methods that might be helpful. They do have the word "Interpolate" in their name.

Did this help?

Hey _Aka_.

Thanks so much! That did help. The first code code example that wasn't working was an embarassing error on my side  Blush haha. So let's ignore that!

I was able to find all the answers to my questions in that api document.
Reply
#4
Glad to know that everything is fine now. Feel free to ask if you encounter any issue.
Have a nice day
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
  How to get length starting from one spline to connected nth spline Dragon-3623 1 1 05-14-2024, 04:52 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: