Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by PeterAS17 · Jul 02, 2015 at 12:35 PM · unity 5physicsvector3trainrail

Why does the train jump?

Hello everyone,

I'm trying to make a train that follows the track, but every single time, the wheels just jump out the track without an apparent reason.

I've already tried to set the collision detection to Continuous Dynamic, Continuous and the default one, Discrete, but they still jump out of it.

To make it displace itself, I add a force to the wheels, with the direction of the red rays you see in the video itself.

Is there a way to prevent this from happening?

Video's here

Thank you, PeterAS17

Comment
Add comment · Show 9
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 AngryBurritoCoder · Jul 02, 2015 at 01:04 PM 0
Share

You should not use actual physics for trains ( in my opinion atleast ), it would be better to fake it

avatar image PeterAS17 · Jul 02, 2015 at 01:06 PM 0
Share

What do you think would be better then? :) ($$anonymous$$nowing that I will have curves)

avatar image AngryBurritoCoder · Jul 02, 2015 at 01:11 PM 1
Share

well, there can be a few ways to fake it, one way could be using a waypoint system, so that the train follows each waypoint on the track

avatar image PeterAS17 · Jul 02, 2015 at 01:19 PM 0
Share

@AngryBurritoCoder yeah, already thought of that way, but it wouldn't look as good as with physics in my opinion... that's why I'm asking for this method. Plus, with the waypoint system, stopping in stations would be harder to make I would say...

avatar image n1gth · Jul 02, 2015 at 01:29 PM 0
Share

I agree about not using physics here - it's too low level - you'd want to use physics if something got in the way of the train, or if some boxes are balanced on top of the train. For moving it, use waypoints as suggested.

However, if you really want to use physics, try adjusting the mass of the train, and add/improve the dampening setup (basically suspension) to cushion it... but again I$$anonymous$$HO it's going to be a lot of effort to solve a problem that could be better solved a different way.

Show more comments

1 Reply

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

Answer by RayJr · Jul 02, 2015 at 01:36 PM

You can take the jitters out of it by adding angular drag. Add enough and the train will just sit still. You'll need to add more force to make it move again of course and will take some playing around to get the right balance. In fact, you might end up with a much more train like feel if you make it nice and draggy.

EDIT: I do agree with the guys above saying that physics might not be the best idea. But if you intend on crashing the train or want hills and things to affect it you'll want to stick with physics.

Comment
Add comment · Show 7 · 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 PeterAS17 · Jul 02, 2015 at 01:49 PM 0
Share

I did try adding some angular drag, but in most cases, it just made the train jump even more! :P

But I will try their method as well, to see how perfect it can be.

But just as I asked there, how can I make the train turn with the waypoint system??

avatar image RayJr · Jul 02, 2015 at 01:57 PM 0
Share

It's somewhat of a manual process. Simply put, you add a bunch of objects along the track and then make the train move toward each one, in order, until it hits each one. After it reaches the first, move it toward the second and so on.

You can probably be sure that any train you've seen in a game isn't using the level of physics you're trying to accomplish here with the wheels and tracks.

If you wanted to stick with physics you could even try making the collider on the train a big rectangle along the bottom that sits flat on the ground. Then your track being two long (invisible) colliders that go on either side of the track. $$anonymous$$ake the train light and the 'tracks' really heavy and give the train force. Assign a material with low friction.

avatar image PeterAS17 · Jul 02, 2015 at 02:01 PM 0
Share

So (just to be sure), with the waypoints system, I have to make every single point for a curve, right?

Second, I didn't understand the method with the physics... even if that worked on a straight line, it would probably get stuck against corners, if it's an underground, because it's a cube collider...

avatar image RayJr · Jul 02, 2015 at 02:08 PM 0
Share

For the curve, technically you could script it but making way points would be easier I would think.

You could also use a Nav$$anonymous$$esh and make the only walkable path the track. then you would only need waypoints at the end where you want the train to go.

For the physics, you could make the train collider a sphere, but lock the rotation so it doesn't fall over. I've never done something like this, but I don't think it's impossible. it would take some trial and error.

avatar image PeterAS17 · Jul 02, 2015 at 07:13 PM 1
Share

Nav$$anonymous$$esh system is working perfectly. Thank you so much for your help! :D (Thank you @AngryBurritoCoder and @n1ght as well! :) )

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

25 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

Related Questions

why does my train jump off the tracks? 0 Answers

2.5d Player Controller 0 Answers

Pushing a ball in a direction -1 Answers

Collision work on pc emulator but not on android device 0 Answers

Excluding Vertices from Cloth Colliders in Unity 5 4 Answers


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