Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
1
Question by danijel123 · Aug 25, 2019 at 11:53 AM · unity 4.6

How to make a heavy bag (for punching ) heavier ?

Im making a game in VR in which I punch a boxing heavy bag with gloves . I have a Configurable joint on it is attached (at the anchor) a heavy bag . In the heavy bag object I have a rigidbody with a maximum amount of mass but its still not heavy enough as It gets punched it should barely move . I dont wont to add drag to the heavy bag as it makes it very unrealistic.

I tried adding a script to the gloves which check the moment the gloves collide with the bag and tried to downplay the force that is generated by the punching, but that doesn`t work either . The script is BagPunchScript (only the collider code):

  void OnCollisionEnter(Collision other) {
        
   
     Rigidbody otherR = other.gameObject.GetComponent<Rigidbody>();
    //check the impact angle

     Vector3 avgPoint = Vector3.zero;
     foreach (ContactPoint p in other.contacts)
     {
         avgPoint += p.point;

     }
     avgPoint /= other.contacts.Length;

     Vector3 dir = (avgPoint - transform.position).normalized;
     otherR.AddForceAtPosition(dir * 0.01f * rBody.velocity.magnitude, avgPoint); //downplay the force of the hit 


     if (other == null)

          return;
      
     
     
 
 }


Any suggestions ?

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 Meishin · Aug 25, 2019 at 12:48 PM 0
Share

Quite a stupid comment from my end, but did you try reducing the mass of the player / gloves ?

avatar image Glurth · Aug 25, 2019 at 04:43 PM 0
Share

Add a debug.log to that: I suspect it is being invoked multiple times. Since the real gloves are not affected by the virtual heavy-bag, you may need to take special measure to ensure the impact- force is transferred to the heavy-bag only once.

Also, might want to give Force$$anonymous$$ode.Impulse (optional parameter for AddForceAtPosition) a shot.

edit: oh.. just spotted this.. you probably want to check (other==null -> return) at the TOP of this function, BEFORE you use it.

avatar image danijel123 Glurth · Aug 26, 2019 at 11:56 AM 0
Share

I looked at the Force$$anonymous$$ode.Impulse unity documetation and I having problem understaing how to implement it for my use case. Have you got any experience with it ? Tnx

avatar image Glurth danijel123 · Aug 26, 2019 at 03:30 PM 0
Share

To use impulse mode simply add the optional parameter for the AddForce function eg.

 otherR.AddForceAtPosition(dir * 0.01f * rBody.velocity.magnitude, avgPoint, Force$$anonymous$$ode.Impulse);  // added optional param after the avgPoint param

Based on my physics classes, an impulse will apply a force only once, over a single moment in time, as opposed to applying the force over a time period. The documentation is certainly not very clear on this, and I'm not sure it will work in your case- but since it's so easy to try out, suggest giving it a shot.

Also, were you able to confirm the force is only applied once, per punch?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by YetAnotherKen · Aug 25, 2019 at 10:16 PM

Meishin has it right. I remember seeing in a training video that the physics engine calculates how much two masses can affect each other based on their relative mass. So, to make the gloves make the bag move less you lower their mass. Or if you are just applying force to the bag, then reduce the amount of force being used.

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 danijel123 · Aug 26, 2019 at 11:47 AM 0
Share

I tried lowering the mass of the gloves to o.oooo1 and the mass of the bag to 100000, its still the same force applied. Note that the gloves are kinematic. I`m strating to think that my configurable joint (to which the bag is attached ) is the problem somehow ?

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

110 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

Related Questions

How to make questions & answers random in my script C#? 1 Answer

what is the meaning of this error BCE0019: 'position' is not a member of 'Object'. when i switch to android this error occurs but for pc platform code works fine no error, please tell me the reason behind this error. 1 Answer

How do i change a bool to true on collide when the bool is on a different script 2 Answers

SetScriptingDefineSymbolsForGroup 1 Answer

iOS 64 Bit - game freezes for some seconds? 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