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 /
avatar image
0
Question by JDelekto · Apr 14, 2018 at 10:32 AM · rigidbodyjointsrotation axisconstraintstrain

How can I create a joint between objects which only allows for rotation around an axis?

I am trying to design a rather simple "multi-car" train and have decided to create a prefab for each of the cars. My ultimate goal is to be able to hinge one or more of these cars together and have them run along a single-rail track created with Dreamteck Splines.

My prototype for the car is rather simple: I have a capsule for the body of the car and at the bottom of one of the lengths of the capsule, I have a flattened cylinder which is partially recessed into the cylinder and is going to provide the base for my "slot" which will run along the rail. In the provided image, the red flattened cylinder is my wheel base and the yellow capsule is the train car. The train car has a rigid body attached.

What I would like to accomplish is somehow linking the cylinder to train car such that: a) the cylinder is synchronized with the train car as it moves in space, and b) the cylinder can rotate a full 360 degrees in either direction, with a center of rotation that is perpendicular to the center of the cylinder and through the body of the capsule. I have resolved (a) by parenting and positioning the capsule and cylinder components to a "TrainCar" game object, so they can move independently.

I would like to now try to resolve (b) by making sure that the cylinder cannot move relative to the capsule, with the exception of only rotating freely around that axis. I have looked at the different joints and it looks like all of the joint types with the exception of the fixed joint might allow for this type of behavior. The configurable joint (which the documentation notes that all other joints derive from) seems pretty daunting in the number of settings.

That being said, can I use one of the simpler joints to do what I am trying to accomplish? If not and I need to go with the configurable joint, which settings would I need to play with to accomplish my goal?

The reason I am doing this is because I want to have one "main" train car which follows a spline. I had successfully added a hinge joint between multiple cars, however, as the lead car followed the spline, the remaining cars hinged as expected but of course did not follow the smooth curves. I had resorted adding a spline follower to each car, but I then had to apply an offset to all cars so they would be behind one another and when the main train car stopped, they all stacked up in one place.

I would like to have a train I can construct of any arbitrary number of these cars, have only one main train following a spline (and the slots of the cylinders on each car follow a rail generated from the spline), but have all cars hinged and smoothly follow all curves of the track.

Any guidance would be greatly appreciated!

![alt text][1] [1]: /storage/temp/114972-railcar.png

railcar.png (50.5 kB)
Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Captain_Pineapple · Apr 14, 2018 at 12:58 PM

I'm not sure if i got correctly what you are trying to do with respect to your cylinder and capsule but try the following:

  • both capsule and cylinder get a rigidbody.

  • give the capsule a hinge joint.

  • Set the connected body to the cylinders rigidbody.

  • set the joints axis to the axis of the capsule that you want your cylinder to rotate around.

  • set the anchor Position of the joint to the position of your cylinders transform.

with this i think it should produce what you are looking for.

For your problem b) i can just think of getting your offset calculation to work. I can't really see a solution to this which relys purely on physics.

Comment
Add comment · Show 1 · 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 JDelekto · Apr 14, 2018 at 06:31 PM 0
Share

Thank you for the hint, I will give this a try. Basically if you look at the image I presented, if you flip the capsule upside-down so that the red cylinder comes resting on the ground, I would like either the capsule to spin 360 degrees around the Y axis (cylinder) if the cylinder is stationary or the cylinder to spin around its Y axis if the capsule is stationary.

I am going to add a "sled" (two small rails) attached to exposed cap of the cylinder with colliders, the sled will be parallel to the length of the capsule. A single rail will be generated by the spline and the sled will fit over the top of this rail. If I connect, for instance, 5 of these cars together, I want the sleds on the red cylinder to stay on the confines of the track, yet the capsule can rotate as each of the connected curves rounds a corner. Each train is hinged together, each cylinder on the train is confined to the track, but all the cars should theoretically follow the main spline follower (lead car) without being followers themselves. Anyhow, that's the theory...

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

102 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

Related Questions

How do I connect multiple spheres using joints and make a character? 1 Answer

Remove rigidbody component 1 Answer

Adding force to an structure composed of multiple rigidbodies makes uneven movement 0 Answers

Changing Rigidbody.Constraints on Keypress 0 Answers

How do I move stacked cubes in a dynamic way? 0 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