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
  Bug: Save Generator Outputs still saves outputs if object is disabled curvymesher 1 2 08-30-2024, 09:19 AM
Last Post: _Aka_
  Player move with object mcarman 4 8 07-29-2024, 06:49 PM
Last Post: mcarman
  Nested Spline Volume Spot Instantiation merobbins5 3 6 07-26-2024, 09:58 AM
Last Post: _Aka_
  Left-right movement, and spline follow shihaya 3 8 07-12-2024, 12:50 PM
Last Post: _Aka_

Forum Jump: