• 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 justaddice83 · Aug 19, 2015 at 03:29 PM · physx

Setting targetAngularVelocity in ConfigurableJoint has no affect!? Works in Unity 4, but not 5 :(

The ConfgirableJoint is set to Velocity AngularXDrive Mode, and all motion Locked except Angular X Motion. The code simply adjust targetAngularVelocity, but has no affect.

Can't get the code any simpler than this;

 using UnityEngine;
 using System.Collections;
 
 public class TargetAngularVelocity_Test : MonoBehaviour
 {
     public ConfigurableJoint joint;
    
     void FixedUpdate()
     {
         if( Input.GetKey("q"))
             joint.targetAngularVelocity = new Vector3(-1, 0, 0);
            
         else if( Input.GetKey("a"))
             joint.targetAngularVelocity = new Vector3(1, 0, 0);
     }
 }


I can see targetAngularVelocity being changed in the ConfigurableJoint component in the editor (Unity 5.1.2f1), but no update on the transform. When I change the value in the editor (by just 0.1) during run-time, then viola, it starts moving.

Attached is the Unity package, so you can see the ConfigurableJoint settings. Basically XDrive mode is set to Velocity.

The above code works fine in Unity 4. Anyone got any ideas what I might be missing?

Thanks

[1]: /storage/temp/52370-targetangularvelocity-test.zip

targetangularvelocity-test.zip (5.8 kB)
Comment
Add comment · Show 2
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 justaddice83 · Sep 01, 2015 at 04:31 PM 0
Share

Bump. Any one have any idea what I am missing?

avatar image dansav · Sep 10, 2016 at 10:56 PM 0
Share

Did you figure out an answer to this problem? I'm having the same issue. I have a joint attached to a kinematic joint and nothing moves anymore, this worked find in 4.7. I'm now using 5.3.5.

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by dwaldrum · Jan 23, 2017 at 03:50 PM

The problem is usually not the rigidbodies sleeping, but in fact the need to add a damper value higher then 0.

If you checkout the docs for joints in PhysX, specifically the section on drives (http://docs.nvidia.com/gameworks/content/gameworkslibrary/physx/guide/Manual/Joints.html) you'll see the following formula used to calculate the force of the drive:

force = spring * (targetPosition - position) + damping * (targetVelocity - velocity)

So the force will be the damping value * the targetVelocity - the current velocity. With a damping of 0 the force will always be 0.

I've experimented with this and so far can't find an exact value to use but it works roughly like this.

If you multiply your desired velocity * your damping value, it needs to be just over 10 times the mass value of the mass you want to be able to move.

So for example, I created an elevator using a simple platform and a piston below it. If I want the max load of the elevator to be 1000 mass, and a desired velocity of 1, I would set my damping to be 11,000.

This would always move the elevator at the same velocity (1) up until the point you loaded it with over 1000 mass on the platform and it would then not be able to raise the elevator and would start to drop.

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 Michcio174 · May 25, 2017 at 10:03 PM 1
Share

I confirm this solution. However I didn't know why it worked - thank you for detailed explanation.

Am I the only one thinking that force named "damping" being used to set joint in motion is totally bonkers? And what is even more misleading is Unity 5.6 documentation on Configurable Joint. It mentions setting in joint drives named "mode" that can be set to position or velocity. I guess in previous versions it was enough to set it to velocity and then set the actual velocity. But now "mode" is depreciated and it seems that using damping is the only way to get the joint moving.

avatar image
0

Answer by Disavowed · Mar 21, 2016 at 09:57 AM

Probably your attached rigidbody to object is sleeping, try to wake it up before using ConfigurableJoint's attributes.

   if(this.gameObject.GetComponent<Rigidbody>().IsSleeping()){
                         this.gameObject.GetComponent<Rigidbody> ().WakeUp ();
   }

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 dansav · Sep 10, 2016 at 10:59 PM 0
Share

Are kinematic objects considered to be asleep? I have a joint connecting 2 cubes, one is free to spin along its x axis the other one is kinematic. Is there any documentation on why this has changed?

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

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

29 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

Related Questions

Can physx do hair physx like in the WWE 2010? 1 Answer

Dynamic animation and physics 0 Answers

Is there a Distance Constraint 3D or Distance Joint 3D in Unity? 2 Answers

multithreading physX 1 Answer

PhysX on ATI Cards 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges