Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reversing over Connection CP from Junction
#1
How do I set the CP / Spline Controller settings in the inspector to enable a train to reverse direction over a Connection with MDJunctionControl.UseJunction = true.  

- Curvy 6.1.0 / Unity 2019.2.16
- followed the example scene 12 to create a simple train track layout with a spline A (main track) and a spline B (siding track), connected at a single CP.  The splines are not closed loops.
- created a train with 2 cars, each with 3 spline controllers (for the car body and the 2 wheel sets on each car).
- the train can travel both forward and backward along the main line (across the connection) with MDJunctionControl.UseJunction = false.  The train cars do not change direction while reversing which is the way I have selected.  This part works fine.
- the train can travel onto the siding track with MDJunctionControl.UseJunction = true.  It can then travel forward and backward along the siding track.  This part works fine.

   

---> the issue is if I try to back the train from the siding track onto the mainline, it gets all messed up upon reaching the connection CP and progress stops.  The spline controllers bounce back and forth across the CP and the overall train just stays there.
- the spline controllers on the train parts remain set to spline B (the siding track) after reaching the CP
- different combinations of MDJunctionControl.UseJunction, FollowUp, orientation direction settings, etc. seem to have no effect.

   

   

I think its most likely that I don't have the settings arranged correctly?  I've tried lots of different combinations over the past 2 days with no result.  What settings might make reversing through a connection from the junction spline work?
Reply
#2
Hello
Is it possible for you to send me your test project (or scene and necessary assets)?
Thanks

PS: before sharing anything, please keep in mind that this forum is public, so do not share here things you want to keep private. Also please do not share Curvy Spline's content publicly. You can always PM me or send me an email
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
What I can do without seeing your use case is that the junction is handled in the event handler of the On Control Point Reached event. The event handler used in the example scene is meant for the usage of the example. You might need to modify it depending on your own use case. I can help you more once I have your reproduction setup
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
Thank you - I'll make a simple scene and email.
Reply
#5
Hi,
After looking at your project, here is the solution:
Replace the code assigning the value of ConnectionBehavior with this:
Code:
           if(splineController.MovementDirection == MovementDirection.Forward)
           {
               if (jc && jc.UseJunction == false)
                   splineController.ConnectionBehavior = SplineControllerConnectionBehavior.CurrentSpline;
               else
                   splineController.ConnectionBehavior = SplineControllerConnectionBehavior.RandomSpline;
           }
           else
               splineController.ConnectionBehavior = SplineControllerConnectionBehavior.FollowUpSpline;
Here is the exaplanation of what was wrong in your code:
You were telling the train to, when on the side spline and reversing on a connection with UseJunction set to false, to continue on the current spline. That current spline was stopping at the connection, so it is normal that the train remains stuck there. You had to tell it instead to get back to the main spline.
The documentation of SplineControllerConnectionBehavior.FollowUpSpline reads as follow:
"Move to the spline containing the Follow-Up if any. If none, continue moving on the current spline, ignoring the connection."
Which is perfect for your use case: when on the side spline the follow up is the main spline, and when on the main spline there is no follow up.

Is it clear?
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
#6
It works perfectly now! Thank you so much - I'm so happy and very grateful for your help with this. My train project is now back on track!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Bug Changing spline connection in inspector causes splines to revert to defaults lacota 3 3 Yesterday, 07:55 PM
Last Post: _Aka_
Thumbs Up Can't delete connection lacota 3 4 03-16-2024, 11:34 AM
Last Post: _Aka_
Lightbulb Junction & Connection Navigation System Design SAMYTHEBIGJUICY 4 13 11-27-2023, 01:04 PM
Last Post: _Aka_
  Connection "next' control point jh092 3 15 11-22-2023, 11:47 AM
Last Post: _Aka_

Forum Jump: