Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Follow Up Spline Issue
#1
Hi,

I am using the Curvy Spline plugin to create a racing style game. I have created 3 scenes, and each scene has 1 spline for the path. I then load in each scene to create the full race track. Is it possible to connect all of the splines together across all 3 loaded scenes, so that when my car drives through "scene 1" and it approaches the end of the spline, it will get the spline on "scene 2" and continue driving until scene 3 etc.?

At the moment my code kinda looks like this, to set it up:

Code:
for (int i = 0; i < m_raceTracks.Count; i++)
{
   CurvySpline currentTrack = m_raceTracks[i].GetComponent<CurvySpline>();
   if (currentTrack != null && i > 0)
   {
       ChunkSpline previousTrack = m_raceTracks[i - 1].GetComponent<ChunkSpline>();
       if (previousTrack != null)
       {
           previousTrack.LastVisibleControlPoint.SetFollowUp(currentTrack.FirstVisibleControlPoint);
       }
   }
}

So I set the 'Follow Up' of the previous spline's last control point (which is a connection) to the next spline's first control point (which is also a connection).

On each of the splines, let's say they all have 5 control points to easily explain:

On Spline 1 - the starting spline, I have only CP0005 set as a Connection point, the "Head to" dropdown box is empty, and I cannot select anything here. CP0005 has the "Head To Spline Start" checkbox Ticked.

On Spline 2 - the middle spline, I have CP0000 and CP0005 set as Connection points, the "Head to" dropdown box is empty, and I cannot select anything here. CP0000 has the "Head To Spline End" ticked and CP0005 has "Head To Spline Start" ticked.

On Spline 3 - the end spline, I have only CP0000 as a Connection point, the "Head to" dropdown box is empty, and I cannot select anything here. CP0000 has the "Head To Spline End" ticked.


On my car, I have the Spline Controller script attached to it, the position mode is set to Relative and start position is 0. The 'Connections Handling' is set to Follow Up Spline and Allow Direction Change = true.


Does all of this seem okay? I could find anywhere for documentation or code examples for how to set up Follow Up on the splines.

Any help would be greatly appreciated,

Thanks!
Reply
#2
Hi,
What Curvy version do you use?
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
If A is a follow up of B, they both need to be part of the same connection, which is not your case if I understand properly. So before setting the followup, you should connect the cps with the same connection. This is what I do in the attached scene and code.
Your use case definitely made me realize that:
* SetFollowUp should have a feedback when called on two CPs not being part of the same connection
* Connection.AddControlPoints should have a feedback when trying to add A to a connection while it is already part of another connection. For now the method just returns with no feedback
I will add this feedback in one of the comming updates
My attached scene has all the splines in the same scene. This is different than your use case, but I don't think it will impact the final result. Let me know if you can't manage to make it work with multiple scenes.

Have a nice day


Attached Files
.zip   RuntimeFollowup.zip (Size: 6.55 KB / Downloads: 1)
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#4
(07-24-2019, 06:20 PM)_Aka_ Wrote: If A is a follow up of B, they both need to be part of the same connection, which is not your case if I understand properly. So before setting the followup, you should connect the cps with the same connection. This is what I do in the attached scene and code.
Your use case definitely made me realize that:
* SetFollowUp should have a feedback when called on two CPs not being part of the same connection
* Connection.AddControlPoints should have a feedback when trying to add A to a connection while it is already part of another connection. For now the method just returns with no feedback
I will add this feedback in one of the comming updates
My attached scene has all the splines in the same scene. This is different than your use case, but I don't think it will impact the final result. Let me know if you can't manage to make it work with multiple scenes.

Have a nice day

Hey! thanks for your help, that solution worked.

However my next issue is about the spline's not syncing up with each other. For some reason the spline seems to "wrap" back on itself. All of my splines are flat, but when these 2 splines are connected together, they don't connect seamlessly at the 2 points, they loop? See images below.

The first image is how it looks in-game, the second image shows how the 2 splines wrap around each other, the 3rd image shows how it is supposed to look.

Thanks!

[Image: pugwNhR.png]


[Image: cUht5CO.png]


[Image: qoJnmqv.png]

://imgur.com/cUht5CO
Reply
#5
I'll take a look at this later today, but I have a question first:
Do you need the Follow up feature only to make the controller switch between splines? Or do you need it to modify the spline's shape too?
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#6
(07-25-2019, 01:04 PM)_Aka_ Wrote: I'll take a look at this later today, but I have a question first:
Do you need the Follow up feature only to make the controller switch between splines? Or do you need it to modify the spline's shape too?

Just to make the controller switch between splines.
Reply
#7
You don't need follow ups then.
Follow-ups are there to be able to smoothly connect splines whose geometry depends on more than the adjacent CPs. More about the subject here:
https://curvyeditor.com/documentation/sp...#follow-up

In your case, just connect the CPs, with no follow ups setting, and then go to the spline controller, "Connection handling" section, and set it to "Random Spline" with "Reject current spline" set to true. Since you connect only two splines, selecting a random spline other than the current one will automatically select the other spline.

Did it work?
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#8
(07-25-2019, 02:08 PM)_Aka_ Wrote: You don't need follow ups then.
Follow-ups are there to be able to smoothly connect splines whose geometry depends on more than the adjacent CPs. More about the subject here:
https://curvyeditor.com/documentation/sp...#follow-up

In your case, just connect the CPs, with no follow ups setting, and then go to the spline controller, "Connection handling" section, and set it to "Random Spline" with "Reject current spline" set to true. Since you connect only two splines, selecting a random spline other than the current one will automatically select the other spline.

Did it work?


Yep, this worked! Thank you Smile
Reply
#9
You are welcome
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
  Curvy Spline mover is jerky BlankMauser 5 66 08-16-2019, 09:31 PM
Last Post: _Aka_
  Camera wobbles on too long spline (100km+) Vectorvision 10 267 08-01-2019, 12:35 PM
Last Post: _Aka_
  Closest point From a Ray (a line), to the spline UsernameHed 5 168 07-31-2019, 03:57 PM
Last Post: _Aka_
  Automated spline generation between objects Alexander Wieser 1 148 07-13-2019, 11:55 AM
Last Post: _Aka_

Forum Jump: