playMaker

Author Topic: Set Hinge Joint Properties (3d)  (Read 6500 times)

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2488
  • Yup.
    • View Profile
    • Cleverous
Set Hinge Joint Properties (3d)
« on: August 20, 2014, 06:10:35 AM »
You can now set the Spring, Motor and Limit properties of a Hinge Joint.

We can do the other joints if necessary.

//Edit
// There's actually one already on Ecosystem. Will get sorted, but this one is more fleshed out with tooltips, all of the joint variables and a couple of minor structure changes inline with how the 2d joint actions were done.
« Last Edit: August 20, 2014, 07:27:08 AM by Lane »

szomaza

  • Sr. Member
  • ****
  • Posts: 253
    • View Profile
Re: Set Hinge Joint Properties (3d)
« Reply #1 on: August 22, 2014, 11:28:49 PM »
Thanks for this Lane, it will be great but currently I get:

"Assets/PlayMaker/Actions/SetHingeJointProperties.cs(199,40): error CS1061: Type `UnityEngine.HingeJoint' does not contain a definition for `enableCollision' and no extension method `enableCollision' of type `UnityEngine.HingeJoint' could be found (are you missing a using directive or an assembly reference?)"

Br,
szomaza

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2488
  • Yup.
    • View Profile
    • Cleverous
Re: Set Hinge Joint Properties (3d)
« Reply #2 on: August 23, 2014, 06:54:54 AM »
What unity version?

szomaza

  • Sr. Member
  • ****
  • Posts: 253
    • View Profile
Re: Set Hinge Joint Properties (3d)
« Reply #3 on: August 25, 2014, 12:17:15 AM »
Oh, yes, I am currently at 4.3.4f1.
I'll try updating to the latest and see how it works with that...

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2488
  • Yup.
    • View Profile
    • Cleverous
Re: Set Hinge Joint Properties (3d)
« Reply #4 on: August 26, 2014, 12:28:18 PM »
Did that happen to fix the error?

szomaza

  • Sr. Member
  • ****
  • Posts: 253
    • View Profile
Re: Set Hinge Joint Properties (3d)
« Reply #5 on: August 27, 2014, 05:59:03 AM »
Sorry, I could not update yet. I need a couple of more days.
(some other serious development going on beside my experiments)

Of course I'll comment this thread with any new findings when they finally happen.

Br,
szomaza

szomaza

  • Sr. Member
  • ****
  • Posts: 253
    • View Profile
Re: Set Hinge Joint Properties (3d)
« Reply #6 on: September 04, 2014, 03:49:13 AM »
Finally updated to 4.5.3f3 and the error message is gone.
Thank you for this script Lane.

Will try it out soon.

Br,
szomaza

szomaza

  • Sr. Member
  • ****
  • Posts: 253
    • View Profile
Re: Set Hinge Joint Properties (3d)
« Reply #7 on: September 06, 2014, 01:19:35 AM »
So far I tried setting the "Spring - Target Position" and that one works as expected.

Thanks,
szomaza

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2488
  • Yup.
    • View Profile
    • Cleverous
Re: Set Hinge Joint Properties (3d)
« Reply #8 on: September 06, 2014, 06:45:09 AM »
Cool =)

szomaza

  • Sr. Member
  • ****
  • Posts: 253
    • View Profile
Re: Set Hinge Joint Properties (3d)
« Reply #9 on: September 07, 2014, 10:12:03 PM »
I just found one thing that needs fixing.
I am continuously setting some spring joint properties, then when the game object is destroyed the application stops with this error:

Code: [Select]
MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
UnityEngine.GameObject.GetComponent[HingeJoint] () (at C:/BuildAgent/work/d63dfc6385190b60/artifacts/EditorGenerated/UnityEngineGameObject.cs:29)
HutongGames.PlayMaker.Actions.SetHingeJointProperties.SetProperties () (at Assets/PlayMaker/Actions/SetHingeJointProperties.cs:159)
HutongGames.PlayMaker.Actions.SetHingeJointProperties.OnUpdate () (at Assets/PlayMaker/Actions/SetHingeJointProperties.cs:152)
HutongGames.PlayMaker.FsmState.OnUpdate ()
HutongGames.PlayMaker.Fsm.UpdateState (HutongGames.PlayMaker.FsmState state)
HutongGames.PlayMaker.Fsm.Update ()
PlayMakerFSM.Update ()

For example iTweenScale (which I also use continuously on the same game object) does not cause this crash just stops in the state.
Please fix this.

Thanks in advance,
szomaza

szomaza

  • Sr. Member
  • ****
  • Posts: 253
    • View Profile
Re: Set Hinge Joint Properties (3d)
« Reply #10 on: July 18, 2015, 04:25:29 AM »
Hi Lane,

I just got this error in Unity 5.1.1f1:
Code: [Select]
Assets/PlayMaker Custom Actions/Physics/SetHingeJointProperties.cs(270,41): error CS0619: `UnityEngine.JointLimits.minBounce' is obsolete: `minBounce and maxBounce are replaced by a single JointLimits.bounciness for both limit ends.'
So I changed these two lines:
Code: [Select]
//_limits.minBounce = minBounce.Value;
_limits.bounciness = minBounce.Value;

//_limits.maxBounce = maxBounce.Value;
_limits.bounciness = maxBounce.Value;

Hope it will work just like before.

Please update it here:
https://github.com/jeanfabre/PlayMakerCustomActions_U3/blob/master/Assets/PlayMaker%20Custom%20Actions/Physics/SetHingeJointProperties.cs
 if this is the proper way to fix the problem.

Br,
szomaza

Bqlqzs

  • Junior Playmaker
  • **
  • Posts: 52
    • View Profile
Re: Set Hinge Joint Properties (3d)
« Reply #11 on: July 18, 2015, 02:31:51 PM »
This action is very cool, but at now, I have a very interesting problem with this.

I like to control the motor, with set "target velocity"

I can set the value and the new value is show in the editor inspector but not moving the object.

If I just edit the value with my mouse or type numbers in the inputfield in the inspector the object is moving, so my gameobject setup is good.

I also tried to control this with c# script, but it also not moving, just filling up the input field.

Anybody know any solution?

szomaza

  • Sr. Member
  • ****
  • Posts: 253
    • View Profile
Re: Set Hinge Joint Properties (3d)
« Reply #12 on: September 06, 2015, 12:54:14 AM »
So I moved to Unity 5.1 with my project and this action does not work anymore.
(In Unity 4.6 it still works perfectly.)

All I am setting is the Spring Target Position. I can still see the value being set in Playmaker editor as it runs but the object does not rotate anymore like it does in Unity 4.6.

Is this because?:
https://unity3d.com/unity/whats-new/unity-5.1
Unity 5.1 release notes under Backwards Compatibility Breaking Changes
Physics: Modifying the HingeJoint Limit, Motor, Spring properties will no longer automatically enable the them. You now need to explicitly set HingeJoint.useLimit, useMotor, useSpring.


If this is the problem, I would really appreciate if somebody could modify it.

Thanks in advance,
szomaza

Edit:
There is also talk about these changes here:
http://forum.unity3d.com/threads/5-1-hingejoint-oddities.332115/
Unfortunately I am having problems (since moving to Unity 5.1) with this too:
"... the "autoConfigureConnectedAnchor" option is setting the connected object to WorldCoordinates now instead of LocalCoordinates, which makes things warp around crazily too, if you have it enabled."
« Last Edit: September 06, 2015, 12:59:57 AM by szomaza »

szomaza

  • Sr. Member
  • ****
  • Posts: 253
    • View Profile
Re: Set Hinge Joint Properties (3d)
« Reply #13 on: September 13, 2015, 02:09:55 AM »
I managed to fix the 2nd problem ("the "autoConfigureConnectedAnchor" option is setting the connected object to WorldCoordinates now instead of LocalCoordinates")
by disabling this and setting the vector3 coordinate myself.
More FSM coding work but it seems to work as it did in Unity 4.6 before.

Still having problems with the Hinge Joint Spring target position setting.
I'll make a test scene...

Edit: Setting the spring's target position rotates the object around the hinge properly in the test scene, but not in my project. So there seems to be no problem with this script, as I thought before as it sets the spring target position, just my object doesn't move for some reason.
« Last Edit: September 13, 2015, 02:42:52 AM by szomaza »

Aaddiction

  • Junior Playmaker
  • **
  • Posts: 95
    • View Profile
Re: Set Hinge Joint Properties (3d)
« Reply #14 on: April 09, 2016, 09:25:37 AM »
Could this action be updated in the Ecosystem. Currently it's not working on Unity 5.2. Thank you!