• 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 theonerm2 · Jun 09, 2019 at 12:18 AM · hinge joint

How do I make a Hinge joint move slowly?

I made a long cube with a $$anonymous$$nge joint in the middle of it. I want the player to jump on the cube and I want the cube to slowly rotate on the Z axis as long as force is applied to it. What is happening is as soon as the player jumps on the cube it rotates quickly and the player instantly falls off.

T$$anonymous$$s is a visual example of what I want to happen.

https://youtu.be/K8_-IJYj-8w?t=119

Notice how when the player jumps onto the platform how it moves?

That's what I want to happen.

Comment
Add comment · Show 4
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 Magso · Jun 09, 2019 at 12:52 AM 0
Share

Does your platform have a rigidbody? You could set the angular drag higher.

avatar image theonerm2 Magso · Jun 09, 2019 at 12:55 AM 0
Share

Yes it has a rigidbody and I tried setting the angular drag already. That doesn't solve the issue.

avatar image Magso theonerm2 · Jun 09, 2019 at 01:08 AM 0
Share

I think the video example is scripted, the platform's rotation didn't seem to accelerate. However you could stop the harsh impact by using RigidbodyConstraints.FreezePositionY for one frame in OnCollisionEnter() and then RigidbodyConstraints.None.

avatar image Owen-Reynolds · Jun 09, 2019 at 01:53 AM 0
Share

Increasing the mass of the object should cause the player jumping on it have less of an effect.

And, I think - it's been awhile - a high spring value and a high damper will slow things down. A problem is that springs get stronger the more of a tilt there is, which means it will only tilt so far before the spring stops it. But you can tweak it so it tilts enough for the player to slide off. It will take forever, the first time, but it can be done.

2 Replies

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

Answer by theonerm2 · Jun 09, 2019 at 05:25 AM

I figured out a solution. I had to make 5 zones on my object. 1 zone with -0.05 rotation on the z axis. Another zone with -0.025 rotation on the z axis. A middle zone with no rotation. The 4th zone with 0.025 rotation on the z axis and the 5th zone with 0.05 rotation on the z axis. Each zone is a cube parented to the mainobject w$$anonymous$$ch is the platform the player walks on that tilts. The zones are cubes with the mesh renderer disabled and istrigger is selected on the box collider in it.

T$$anonymous$$s is my code for a zone. Each zone has to have the script attached and the Z axis value has to be changed on each one to allow it to work. It works beautifully.

 public class RotateCubeZone2 : MonoBehaviour
 {
     public bool PlayerInZone = false;
     public GameObject MainObject;
     public Vector3 Rotation;
     public Vector3 RotateBack;
     public Vector3 RotateForward;
     public GameObject Player;
     public bool PlayerWasInZone;
     public Quaternion ZeroRotate = Quaternion.Euler(new Vector3(0f, 0f, 0));
     
 
 
 
 
 
     // Update is called once per frame
     void Update()
     {
         
 
         
 
         if (PlayerInZone == true)
         {
 
             MainObject.transform.Rotate(Rotation);
         }
 
         if (MainObject.transform.rotation ==ZeroRotate)
         {
             return;
         }
 
 
         if (PlayerInZone== false && MainObject.transform.rotation != Quaternion.Euler(new Vector3(0f, 0f, 0))  )
         {
             if (MainObject.transform.rotation.z > 0)
             {
                 MainObject.transform.Rotate(RotateForward);
             }
 
             if (MainObject.transform.rotation.z < 0)
             {
                 MainObject.transform.Rotate(RotateBack);
             }
         }
         
     }
 
     private void OnTriggerEnter(Collider other)
     {
        if (other.gameObject == Player)
         {
             PlayerInZone = true;
             PlayerWasInZone = false;
             
         }
     }
 
     private void OnTriggerExit(Collider other)
     {
         if (other.gameObject == Player)
         {
             PlayerInZone = false;
             PlayerWasInZone = true;
         }
 
     }
 
     
 }
 
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
avatar image
1

Answer by BradyIrv · Jun 09, 2019 at 01:59 AM

Scene Setup: In Hierarchy create an empty game object and add the Hinge Joint component to that object, rename it Hinge (for t$$anonymous$$s example). Then create a cube (or place your model) as a c$$anonymous$$ld of the Hinge and add the Rigidbody component to it as well a the collider (I named t$$anonymous$$s one Platform for testing). alt text


Component Setup: On the Hinge object, set the Rigidbody to be "IsKinematic = true". In the Hinge Joint component, drag the Platform object into the "Connected Body". Then there are some variables in the Hinge Joint component that you will want to play with until it feels right for your game.

  • Use Spring: True

  • Spring Value: How much the platform will push back to its original position

  • Damper: "The give", what will stop the platform from spinning fast when you hop on

  • Use Limits: true

  • Min/Max: The maximum amount of angle that the platform can tilt alt text


I've added a picture of the setup that worked for my test using a standard 3D cube and Rigidbody (Mass 1) as the player jumping onto the platform.


hierarchy.png (1.5 kB)
hingeobject.png (40.6 kB)
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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

109 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

Related Questions

Same object, different scale on different projects both with default project settings 0 Answers

How to make a puch to open door 2D 0 Answers

Wheelchair movement with hinge joint and rotation of controllers? 0 Answers

How do you get the hinge joint working on all Axis? 3 Answers

Hinge Joint Doesn't Move Unity 2018.4.17f1 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