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 /
  • Help Room /
avatar image
0
Question by ntgCleaner · Jul 20, 2020 at 10:04 AM · configurablejoint

ConfigurableJoint does not move when hooked up dynamically.

Hello, I'm brand new to Unity and I'm just playing around with a few ideas. I am currently trying to just make a tractor hook up to a trailer via a ConfigurableJoint. I have the joint hooked up to the trailer and an invisible collider on each tractor and trailer to allow me to know if I'm "close enough" to hook up the trailer.

Once I get close enough, I am able to check what collider is being collided with then I press a button (tab in this case) and the ConfigurableJoint hooks to the tractor.

My issue is that when I hook the trailer up to the tractor, the configurable joint wants to stay in place until it's bumped. I use the tractor to back up into the trailer to bump it just a bit and then everything works as expected. I have everything set to zero, but something must be missing. Below is everything I'm doing:

This script checks the collider, if the collider is the right one, I can press tab and I check whether it's connected or not (with a 1 second delay). Then if I were to hook the trailer up, I give the trailer's connected body the appropriate rigidbody (this might be where the issue is). I also set all of the motions to locked so there's no springyness to the trailer.

 void OnTriggerStay(Collider collider) {
     if (collider.name == "HitchColliderTractor") {
         if (Input.GetKey(KeyCode.Tab)) {
             if (!once) {
                 once = true;
                 Invoke("revertOnce", 1F);
                 if (!trailer.connectedBody) {
                     trailer.connectedBody = collider.GetComponent<Rigidbody>();
                     lockTrailer();
                 } else {
                     trailer.connectedBody = null;
                     unlockTrailer();
                 }
             }
         }
     }
 }

 void revertOnce() {
     once = false;
     Debug.Log("Revert");
 }

 void lockTrailer() {
     trailer.xMotion = ConfigurableJointMotion.Locked;
     trailer.yMotion = ConfigurableJointMotion.Locked;
     trailer.zMotion = ConfigurableJointMotion.Locked;
     trailer.angularXMotion = ConfigurableJointMotion.Locked;
     trailer.angularYMotion = ConfigurableJointMotion.Locked;
     trailer.angularZMotion = ConfigurableJointMotion.Locked;
     jackPos = jack.transform.localPosition;
     jack.transform.localPosition = new Vector3(jack.transform.localPosition.x, 0, jack.transform.localPosition.z);
 }

 void unlockTrailer() {
     trailer.xMotion = ConfigurableJointMotion.Free;
     trailer.yMotion = ConfigurableJointMotion.Free;
     trailer.zMotion = ConfigurableJointMotion.Free;
     trailer.angularXMotion = ConfigurableJointMotion.Free;
     trailer.angularYMotion = ConfigurableJointMotion.Free;
     trailer.angularZMotion = ConfigurableJointMotion.Free;
     jack.transform.localPosition = jackPos;
 }

Below is a pic of the joint settings as default:

alt text

When the trailer hooks up, the rigidbody changes and all of the motions change properly. But for some reason the joint sticks in place until it's bumped. Here's a gif to show what I mean:

http://images.myfpv.io/Trailer_hitch_issue.gif

When I hook the tractor to the trailer (you can see when the hitch arm moves up), the joint doesn't move. The tractor doesn't have enough power to pull the trailer and actually gets pulled back like it's on a strong bungee. If I back up and bump the trailer a tiny bit, the joint moves and everything works perfectly.

Any thoughts? Thank you!

,Hello, I'm brand new to Unity and I'm just playing around with a few ideas. I am currently trying to just make a tractor hook up to a trailer via a ConfigurableJoint. I have the joint hooked up to the trailer and an invisible collider on each tractor and trailer to allow me to know if I'm "close enough" to hook up the trailer.

Once I get close enough, I am able to check what collider is being collided with then I press a button (tab in this case) and the ConfigurableJoint hooks to the tractor.

My issue is that when I hook the trailer up to the tractor, the configurable joint wants to stay in place until it's bumped. I use the tractor to back up into the trailer to bump it just a bit and then everything works as expected. I have everything set to zero, but something must be missing. Below is everything I'm doing:

This script checks the collider, if the collider is the right one, I can press tab and I check whether it's connected or not (with a 1 second delay). Then if I were to hook the trailer up, I give the trailer's connected body the appropriate rigidbody (this might be where the issue is). I also set all of the motions to locked so there's no springyness to the trailer.

 void OnTriggerStay(Collider collider) {
     if (collider.name == "HitchColliderTractor") {
         if (Input.GetKey(KeyCode.Tab)) {
             if (!once) {
                 once = true;
                 Invoke("revertOnce", 1F);
                 if (!trailer.connectedBody) {
                     trailer.connectedBody = collider.GetComponent<Rigidbody>();
                     lockTrailer();
                 } else {
                     trailer.connectedBody = null;
                     unlockTrailer();
                 }
             }
         }
     }
 }

 void revertOnce() {
     once = false;
     Debug.Log("Revert");
 }

 void lockTrailer() {
     trailer.xMotion = ConfigurableJointMotion.Locked;
     trailer.yMotion = ConfigurableJointMotion.Locked;
     trailer.zMotion = ConfigurableJointMotion.Locked;
     trailer.angularXMotion = ConfigurableJointMotion.Locked;
     trailer.angularYMotion = ConfigurableJointMotion.Locked;
     trailer.angularZMotion = ConfigurableJointMotion.Locked;
     jackPos = jack.transform.localPosition;
     jack.transform.localPosition = new Vector3(jack.transform.localPosition.x, 0, jack.transform.localPosition.z);
 }

 void unlockTrailer() {
     trailer.xMotion = ConfigurableJointMotion.Free;
     trailer.yMotion = ConfigurableJointMotion.Free;
     trailer.zMotion = ConfigurableJointMotion.Free;
     trailer.angularXMotion = ConfigurableJointMotion.Free;
     trailer.angularYMotion = ConfigurableJointMotion.Free;
     trailer.angularZMotion = ConfigurableJointMotion.Free;
     jack.transform.localPosition = jackPos;
 }

Below is a pic of the joint settings as default:

alt text

When the trailer hooks up, the rigidbody changes and all of the motions change properly. But for some reason the joint sticks in place until it's bumped. Here's a gif to show what I mean

http://images.myfpv.io/Trailer_hitch_issue.gif

When I hook the tractor up, if I don't bump the trailer, the the joint stays there and the tractor doesn't have enough "power" to pull it, so it actually gets pulled back like it's on a bungee cord. once I back up and bump the trailer, the tractor pulls it just fine.

I hope this is formatted alright, first post on here.

image-6.png (199.2 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 EvilBob99 · Nov 06, 2021 at 04:51 PM

I think if im reading this right you need the movement unlocked and some of the rotation because from what im reading your making unable to move at all which means it has to be in the perfect spot for it to work @ntgCleaner

Comment
Add comment · 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

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

202 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 avatar image avatar image avatar image avatar image avatar image

Related Questions

ConfigurableJoint Projection Angle issues if any axis is locked 1 Answer

Rope Physics - Flying End 0 Answers

How to stop ConfigurableJoint from moving? 0 Answers

How do you make configurable joints play nice with VR controllers? 0 Answers

Help ConfigurableJoint 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