Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Forces and joints, how can i get the data i need?

Discussion in 'Editor & General Support' started by Nanako, Feb 9, 2015.

  1. Nanako

    Nanako

    Joined:
    Sep 24, 2014
    Posts:
    1,047
    Hi all. I have a complex object made of tens of little parts interconnected with a complex web of joints. And each has a carefully calculated break force based on the surface area to surrounding parts (i have all this stuff being autogenerated now,it's no big deal)

    The joints are working perfectly as far as i can tell. When i hit a segment hard enough, its joints break and it falls off, as desired. However this is very binary behaviour.

    What i would like to also do, is have a segment exhibit some kind of effects when subjected to a force that is high, but not high enough to completely break it off (a percentage). Stuff like cracking, shifting, settling, modifying health values or whatever. For this, i need access to forces

    The OnJointBreak event seems to give me a breakforce value which is quite helpful, but of course that's only triggered when a joint breaks, and not when one is just quite strained.

    Is there any way to grab the force data from physX and do stuff with it myself? It must be in there being tracked for joints to function like this. If not, how is it calculated, what does it take into account? I'm guesing everything, and that replicating it myself would be slow and inefficient :(

    Also lastly, the jointbreak doesn't seem to give me any information about WHICH joint broke. Each segment has 2-5 joints connecting it to other segments, so it's kind of important to me when some of them break but not all. How can i figure that out?
     
    fjc likes this.
  2. Nanako

    Nanako

    Joined:
    Sep 24, 2014
    Posts:
    1,047
    poke.

    is data about forces acessible anywhere?
     
    fjc likes this.
  3. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    the rigidbody it's attached to has relative velocity from a collision that might help. Alternatively you can measure how far from origin it goes, and finally you could try actually breaking it to get the force but restoring it directly after (probably wouldn't work well).

    I haven't answered this question properly, so anyone reading could chip in with more info.
     
  4. Nanako

    Nanako

    Joined:
    Sep 24, 2014
    Posts:
    1,047
    I'm thinking of this. Adding in an ADDITIONAL joint with the break force set to the minimum possible value that i'm interested in, and immediately restoring it in the same frame that it breaks. it feels wierd and hacky though.

    Slightly off topic, but can anyone explain exactly how physX resolves collisions? I'd think the normal thing in computing for when two rigid objects collide, is to have them both stop dead (or bounce off, or whatever) instantly. But in reality deceleration happens over a very short, but still significant, timeframe, and the colliding bodies often deform and squash.

    Does physX simulate that in any way? Ie, decelerating colliding objects over some period of time rather than instantaneously?

    because the problem with instantaneous deceleration is that it breaks newton's second law of motion. F=MA. The acceleration results in an infinite value.
     
  5. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Physx penetrates, then based on Min Penetration For Penalty (which might be slightly different in Unity 5), it will determine how much they're allowed to penetrate before being pushed apart.
     
  6. Nanako

    Nanako

    Joined:
    Sep 24, 2014
    Posts:
    1,047
    are they assumed to be colliding, and decelerated, while below this minimum penetration value?

    and is there any way to adjust it on a per-object/material basis? (say to make an object act soft, or rigid)
     
  7. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    In Unity 5:


    Rigidbody.maxDepenetrationVelocity

    public float maxDepenetrationVelocity;

    Description
    Maximum velocity of a rigidbody when moving out of penetrating state.
    Use this property when you want to make your bodies move out of colliding state in a more smooth way than by default.
     
  8. jinendramehta

    jinendramehta

    Joined:
    Oct 4, 2018
    Posts:
    2
    I have tried using maxDepenetrationVelocity but it seems to have no effect. Can you provide an example for using the same?