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 /
avatar image
1
Question by thijsbs · Jun 07, 2014 at 05:49 PM · 2dphysics2d-physicsjointsjoint

HingeJoint2D.GetReactionForce not working

Since the 2D joints in unity do not seem to have a break force/torque built in, I wanted to write it in a script myself by reading the joints reaction force in the following code:

 var breakForce : float = 100;
 private var jointForce : float;
 
 function Start() {
 var joint = gameObject.AddComponent(HingeJoint2D);
 }
 
 function FixedUpdate() {
     jointForce=joint.GetReactionForce;
     if (jointForce>breakForce) {
         Destroy(joint);
     }
 }

The documentation says that HingeJoint2D.GetReactionForce should be possible: http://docs.unity3d.com/ScriptReference/HingeJoint2D.GetReactionForce.html

However unity tells me: 'GetReactionForce' is not a member of 'UnityEngine.HingeJoint2D'. This made me very confused. I hope someone can help me!

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
1

Answer by MinsukCha · Jun 09, 2014 at 08:56 AM

Your code should be something like this:

 var breakForce : float = 100;
 private var jointForce : Vector2;
 var joint : HingeJoint2D;
  
 function Start() {
     joint = gameObject.AddComponent(HingeJoint2D);
 }
  
 function FixedUpdate() {
     jointForce = joint.GetReactionForce ( Time.deltaTime );
     if (jointForce.magnitude > breakForce) {
        Destroy(joint);
     }
 }

GetReactionForce returns Vector2 type. You can't convert to float directly. And declare 'joint' as a HingeJoint2D' type. You might compare jointforce's magnitude with the variable 'breakForce'.

Comment
Add comment · Show 3 · 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 thijsbs · Jun 09, 2014 at 10:45 PM 0
Share

Hey thanks a lot for the reply! Unity now gives me the following error, again I am clueless...

 $$anonymous$$issing$$anonymous$$ethodException: UnityEngine.HingeJoint2D.GetReactionForce
 Boo.Lang.Runtime.DynamicDispatching.$$anonymous$$ethodDispatcherFactory.ProduceExtensionDispatcher ()
 Boo.Lang.Runtime.DynamicDispatching.$$anonymous$$ethodDispatcherFactory.Create ()
 Boo.Lang.Runtime.RuntimeServices.DoCreate$$anonymous$$ethodDispatcher (System.Object target, System.Type targetType, System.String name, System.Object[] args)
 Boo.Lang.Runtime.RuntimeServices.Create$$anonymous$$ethodDispatcher (System.Object target, System.String name, System.Object[] args)
avatar image MinsukCha · Jun 10, 2014 at 01:48 AM 0
Share

What version of Unity are you using? GetReactionForce is available only from v.4.5. Please check it out and upgrade Unity if necessary. Thanks~.

avatar image thijsbs · Jun 10, 2014 at 02:13 PM 0
Share

Ah that must be it. I am still using 4.3 at the moment. Thanks!

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

23 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

Related Questions

Wheel Friction Curve in 2d 0 Answers

New Pointer Effector 2D Help 0 Answers

Make a hinge joint stay firmly in place 4 Answers

Unity HingeJoint2D issues when Flipping ( Negative Scaling ) 1 Answer

Gravity Direction Change 2D 1 Answer


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