Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
12_Train junction point
#1
For the life of me, I cannot seem to see how to change the junction point direction in the scene 12 Trains example scene. I would have thought that the whole purpose of having a UI toggle box was to select between the left and right tracks which would have been a super-useful help in understanding how to do this. Some might say that it would be an, in fact, essential thing to include in a package that features splines and junctions. The ability to change junction directions appears to exist " in theory" , but the example scenes just dont seem to show you how to achieve it in practice. When I tried this scene , I toggled the toggle box on and off numerous times hoping to get some sort of effect only to find that it didnt seem to do anything at all! Frustrating!I have spent more than five hours trying to make a selection between splines so that a character ( esp. a train ) can smoothly transition from one spline to another. I am surprised how difficult this is to accomplish. I would appreciate an example scene that clearly demonstrates how to change the trains direction of travel at a junction.
Reply
#2
Hi,

It is weird that the junction doesn't seem to have an effect. Can you please follow the steps bellow, and let me know if any one of them fails?
1. Open scene 12
2. Press play
3. Do not click on the Use Junction checkbox. The train must go to the right when reaching the junction
4. Exit play mode
5. Reenter play mode
6. Click on the Use Junction checkbox. The checkbox must be become checked. The train must go to the left when reaching the junction.
FYI, the scene 12 is part of the WebGL demo too (as are most example scenes). You can test the junction there too if you wish.


Code wise, the main thing to know is the SplineController.ConnectionBehavior property, which defines how a controller behaves when reaching a junction. Bellow are links to its documentation:
· User manual: https://curvyeditor.com/documentation/co...s_handling
· API reference: https://api.curvyeditor.com/FluffyUnderw...avior.html

Example scene 12 showcases the change of this value dynamically at runtime. The steps are as follow:
1. The checkbox is part of a canvas attached to the control point with the junction (RailtrackPathA.CP0002)
2. The checkbox modifies the value of a custom control point metadata, used to store the state of the junction (script: E12_MDJunctionControl)
3. When the train reaches the junction, it reads the state of the junction, and changes the controller's ConnectionBehavior accordingly (script: E12_TrainCarManager, specifically in the OnCPReached method).

I hope these explanations helped.
Please let me know if you still have questions.

Have a nice
Available for freelance work, feel free to reach out: toolbuddy.net
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Reply
#3
Hi thanks for your response.
It seems that the issue I have located was my own fault, being that I had slightly modifed the E12_TrainManager.cs script to have variable speed ( including negative ( reverse ) ) controlled from a UI slider, which it turns out CurvySplines does not like. And I mean it REALLY doesnt seem to like variable speed for some reason. I have been attempting to modify the E12_TrainManager and E12_TrainCarManager script to accept this but have been unable to achieve a solution, even with assistance from ChatGPT. Any idea if there is a simple way I can achieve this result, that I am overlooking? I am trying to implement a UI slider than modifies the TrainManager.speed and that can go negative, but am getting all sort of adverse results, including jitter, teleportation to the ends of splines and such. Putting speed and positional changes in an update function seems to ruin its capacity to transfer to another spline for some reason.
Reply
#4
25_CGExtrusionAdvanced

Hi,
Controllers inherently don't have an issue with variable speeds. In fact, you can see an example of a variable-speed controller in Scene 25_CGExtrusionAdvanced.

Curvy Splines is not a train simulation asset. The Train Manager in the example scene 12 is just that, an example script. It’s designed for a specific use case shown in the scene and not for all possible scenarios. Therefore, you'll need to modify it or create a new one to suit your needs.

To be able to do that, you need first to familiarize yourself with the controllers. To do that, to first create a single-wagon train—meaning, use a single spline controller. In this setup, I don't foresee any issue with forward/backward movement and junctions, just make sure to read the documentation of the relevant fields. Once you've achieved the desired results with that setup, you can expand the setup by adding multiple wagons. These can be connected using either your custom Train Manager or a modified version of the one provided in Scene 12.

I hope this helped.

Have a nice day.
Available for freelance work, feel free to reach out: toolbuddy.net
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Reply
#5
Thanks !
I am happy to say that I eventually got it to work as desired!
Reply
#6
Glad to read that.
Available for freelance work, feel free to reach out: toolbuddy.net
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  OnAfterControlPointAdded - Control Point is null jh092 5 452 02-04-2025, 09:31 PM
Last Post: _Aka_
  How to generate gameobject on the control point Yang Yi 1 184 12-10-2024, 10:14 PM
Last Post: _Aka_
  Getting Distance from a World Point zorksox 3 289 04-16-2024, 07:30 PM
Last Post: _Aka_
  Avoiding runtime GC allocations on control point position change Ell223 8 584 02-24-2024, 10:43 AM
Last Post: _Aka_

Forum Jump: