Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using curvy for camera pathing, through a procedural level
Wow...curvy has a lot of features. So many that I feel burried in docs. Before I spend days reading all of it...I need a fail fast test...which is to ask on this forum.

I have a game in which the level is built at runtime. For explanation sake, we can call it a maze game. Each component of the level is a prefab and includes a GameObject that representings a control point for my spline. The spline must also be built at runtime. Before the level starts, I build a path through all the control points...that becomes the spline. And now I need to move the camera through the spline. So far, there are a number of packages that can do this for me. The troubling part is that I also want the orientation (quaternion rotation) of the control points to be used in the camera fly through. Basically at the moment that the camera actually passes through a particular control point, I want it's rotation to be that of the control point.

It seems like the spline itself shouldn't align to those camera angles. I could probably manage the rotation of the camera myself, if I knew which control point it was going to next.

Seems like something several people would have done before. Any hints?


pretty much questions for a single post Wink

Well, the solution depends on whether you want to use your own orientation or Curvy's one. Using Curvy, you could set Orientation to "Control Points", then the spline rotation is defined by CP rotations. In alternative, you might get better results to leave "Tangent" mode orientation and just set the first CP's rotation to define the starting Up-Vector (Enable "Orientation Gizmos" in the View-Settings to see the results).

If you have a TF value or distance, it's easy to find the segment you're currently moving over, see the conversion methods API here. Once you have a CP, you can use CurvySplineSegment.NextSegment or CurvySplineSegment.NextControlPoint to walk through the Spline (and PrevSegment etc..). Just lookup the CurvySplineSegment class in the docs.

Btw, Segments and Control Points are two terms for the same class object (CurvySplineSegment), but the first refers to a visible (or computable) part of the spline, while the latter is just used as a Transform (e.g. if you close a spline, the last CP becomes a segment).

Best regards,
I'm still having the most basic of issues. I can see how all the example levels work, but they're all pre-setup in the editor. I'm trying to do stuff completely in code because the game levels are generated at runtime. I get stuck pretty much right at the start trying to do something like...

GameObject cameraGO = MyCamera.gameObject;

I can get it to work using SplineWalker as the component to add, but the docs say to not use this.
Even if I set this part up in the editor (adding the FollowSpline via the editor) I can't figure out how to access the component at runtime...I would have expected this to do it: someGO.GetComponent<FollowSpline>()...

Is there some sample code for how to do this?


I figured out that to access this stuff, you need to specify the entire path to the code. So you do like this...
FluffyUnderware.Curvy.FollowSpline FS = cameraGO.AddComponent<FluffyUnderware.Curvy.FollowSpline>();
Duh....i forgot to do using FluffyUnderware.Curvy; I blame the chaos of investigating 5 different spline packages at the same time.
I recommend skipping the FollowSpline component and adding the few needed API calls to your custom controller. This way you can directly interact with the Spline and do whatever you like...
So far I'm using AlignToSpline as the basis, adding a few bits to that, etc. 

Possibly Related Threads…
Thread Author Replies Views Last Post
  Help with procedural roads and splines ramiroflores 1 6 05-07-2024, 08:57 AM
Last Post: _Aka_
  Curvy Line Renderer for UI Spline? gekido 3 6 04-04-2024, 12:56 PM
Last Post: _Aka_
  8.8.0 is live, and it improves Curvy Generator greatly _Aka_ 1 12 04-03-2024, 03:16 PM
Last Post: _Aka_
  snap to the curve created by the curvy splines segment points ShiroeYamamoto 3 11 04-02-2024, 02:24 PM
Last Post: _Aka_

Forum Jump: