Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by fabi090806 · Apr 13, 2020 at 12:27 PM · splinetrainrail

Does anyone know a spline system with junctions (for a train simulator)?

I've been trying to create my own train sim for a long time now, but always have failed beacuse of not knowing a good way to controll the train and keep it on the track. If anyone knows a free spline tool that alows me to controll a junction trough a C# script or knows a way to pull it of in a other resonable way, please help!

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image streeetwalker · Apr 15, 2020 at 08:56 PM 0
Share

@fabi090806 Hey, I found the discussion I had referred to - I didn't realize that those forums get moved to this forum as answers when they are closed

Hope it helps!:

https://answers.unity.com/questions/1702609/how-can-you-make-a-path-with-a-switch-in-it.html

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by streeetwalker · Apr 13, 2020 at 04:50 PM

@fabi090806, Sebastian Lague on youTube has an excellent spline based road creator that will work perfectly. It allows open or close spline paths.

It does not have junctions built in, but it is easy to create junctions by placing two splines touching or near each other, and then creating a Trigger Collider (can be on an empty object) and placing it at the location where you want a junction. You can then detect the trigger and switch splines for your train. You'd have to work out the details

I did this recently as proof of concept for another person asking for help and it worked pretty slick, though in the end they took Sebastian's code (it's a free download) and modified it to effectively (I don't think actually) join splines. You can do a search on the Unity Forum for that discussion (not this forum).

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image fabi090806 · Apr 14, 2020 at 09:48 AM 0
Share

I am already using Sebastian's spline road creator in my testing/prototype project so it is easy for me to impliment this, thank you!

avatar image fabi090806 · Apr 14, 2020 at 09:57 AM 0
Share

Do you have a link to that discussion or know the keywords to search for? I can't find it on the Unity Forum :/ Because it does not work too well at the moment... The train litteraly faling apart

failiure.jpg (68.9 kB)
avatar image streeetwalker fabi090806 · Apr 14, 2020 at 11:43 AM 0
Share

Sorry, I just spend a half hour searching and I cannot find it, and I cannot find my replies to it, which is weird. I know the date was around Feb 27 of 2020 because that is the creation date of my proof of concept project that I mentioned.

I don't think they would have deleted the thread because as I recall he/she posted the code in their last reply explicitly so that others could use it.

I do recall the gist of poster's code: what they had done was calculate a point on one spline that was closest to the end point of a second spline, so that when the object moved and hit that point they could decide whether or not to switch to the second spline. I don't recall the exact code though.

$$anonymous$$y way of doing it was perhaps simpler, but I did need to fiddle with the locations, curves and twists using by setting the spline point rotations to get a smooth move to the second spline. the spline's location and orientation is hard to judge because it just appears as a line, so I had to move the camera around to make to the spines aligned in all 3 dimensions.

I see in your graphic your train looks like it is rotated 90 degress? That probably has to do with your model's initial rotation - you might need to parent it to an empty transform to set the correct orientation. Off the top of my head, doesn't Lague's code align the objects transform.forward along the direction of motion on the spline?

avatar image fabi090806 streeetwalker · Apr 16, 2020 at 02:26 PM 0
Share

Everytime I moved the trigger my results change and the reason the train is rotated like this is because the joints are going haywire. I have connected the wheels to the train (idk the exact English names) with joints. I have managed to align the trigger exactly on the point where the spline starts, but because there are not just going to be like two junctions but about 50 on every route, I guess I will have to figure out to do it the way you described it...

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

197 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Train Spline controller? 0 Answers

How does one make a train in Unity? 0 Answers

Restraining movement to spline 0 Answers

Creating a train system with little to no code knowledge 0 Answers

I'm having a few issues with (Catmull)Splines that i need help with. 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges