[HELP] Explosiveness and stretching of physical object connections

Post Reply
Favkis
Posts: 3
Joined: Tue Mar 02, 2021 5:11 pm

[HELP] Explosiveness and stretching of physical object connections

Post by Favkis »

Hello, what parameters are for stretching of connected physics? https://www.youtube.com/watch?v=28gX7hilj0U Example at 0:49

And what parameters are for "explosiveness" when physbox is inside of a wall or inside of another physbox? If they clip, they start having very large velocity or something.

Help please I'm learning how physics engines work and yet these two are things I haven't found figured out
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: [HELP] Explosiveness and stretching of physical object connections

Post by drleviathan »

I watched the video. I believe what is happening is: the objects get into a state of interpenetration and the penetration resolution logic separates them but does so in a non-physical way. The penetration resolution logic is pretty good at getting the objects out of overlap while not pumping too much energy into the system (which is important for keeping the simulation stable) but since it is fundamentally "non-physical" it can result in unexpected configurations. However, I'm guessing your main character's sword is being moved in a "non-physical" way too: it is probably being animated about rather than doing something more complicated and costly like computing all the torques on the character's joints required to swing it (not recommended because it is so complicated, but it would result in more correct physical collisions). This non-physical sword motion is introducing the penetration, and since the sword's motion can't react to the collision --> the enemy's body must do all of the reaction.

I don't know what the exact solution/workaround would be. At the moment I have only one idea:

Split the visible sword from its collision by making the sword itself non-colliding and use an invisible dynamic RigidBody to serve at its collider. You would slave the motion of the collider to follow the visible sword as best it can, but since the collider is invisible it will be ok (not visibly offensive) when its position doesn't quite line up with the actual sword, which will happen when the visible sword moves fast, and when the penetration resolution pushes the collider out of the enemy's body. How to make the collider follow the sword is tricky. You could try an impulse update every substep to push the collider toward where it should be, or perhaps you could try using a constraint to tie it to the visible sword location.

You could do it in two steps:

(1) Make the sword itself dynamic and tune its motion to follow the main character's hand and hit the enemies. This will be visibly objectionable because the sword will lag the hand motion and collisions will push the it even farther from the hand.

(2) Once you've tuned the sword's RigidBody for hitting enemies make it invisible and draw a sword at the main character's hand.
Favkis
Posts: 3
Joined: Tue Mar 02, 2021 5:11 pm

Re: [HELP] Explosiveness and stretching of physical object connections

Post by Favkis »

drleviathan wrote: Wed Mar 03, 2021 3:02 pm I watched the video. I believe what is happening is: the objects get into a state of interpenetration and the penetration resolution logic separates them but does so in a non-physical way. ...
...
I don't know what the exact solution/workaround would be. At the moment I have only one idea:

Split the visible sword from its collision by making the sword itself non-colliding and use an invisible dynamic RigidBody to serve at its collider.
Well, my problems were:
Because of bug, sword when attached to hand was always falling, increasing it's velocity higher and higher so everything it touches would fly away.
Sword was separate object that was moving as their own as attachment to hand bone, so it wasn't physical movement.

I did fix both of these problems already (it's old video), when I pick up weapon, it's physbox becomes disabled and copy is added into ragdoll chain that is physical.

What I want to understand is this: I use normal skeletal animations made in blender, so like normal stuff, then I recalculate bone rotations in this animations and apply them to my ragdolls, so they are physicall ragdolls and with X Y Z constraints I move their joints, so they basically repeat skeletal animations but in physics.

First, like with bug on video, why is it when my sword that had insane velocity (like 160352,1,1) touched character, their head started to stretch instead of applying force to all body, how do I control stretchiness? Like, if I get hit by a car, I wont rubber band half a meter from impact.

And second, as I said how I animate my physical ragdoll (it's called active ragdoll if I'm not mistaken), imagine my character is lying on bed, and physboxes for arms/torso/legs are larger than actual mesh geometry, so when character is laying on bed, these physboxes would go inside of a bed and try to jump out violently. What can I do about that, so that things don't jump from static bodies/other rigid bodies when they intersect?
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: [HELP] Explosiveness and stretching of physical object connections

Post by drleviathan »

Because of bug, sword when attached to hand was always falling, increasing it's velocity higher and higher so everything it touches would fly away.
Sword was separate object that was moving as their own as attachment to hand bone, so it wasn't physical movement.
Ah I see: you were slamming the sword transform but not zeroing the velocity.
First, like with bug on video, why is it when my sword that had insane velocity (like 160352,1,1) touched character, their head started to stretch instead of applying force to all body, how do I control stretchiness? Like, if I get hit by a car, I wont rubber band half a meter from impact.
The fact of the matter is: the constraints are "solved" iteratively and eventually the iteration must conclude so that the simulation can go on. When the solving stops before the constraints are well satisfied then they appear "soft" or "stretchy". Some ideas:
(1) Take smaller substeps (e.g. solve the constraints more often)
(2) Make cars drive slow (e.g. tune the content of the game to avoid the problem)
(3) Tune the constraints (there are some tuning knobs in the solver itself but I don't have much experience adjusting them) or try different stiffer constraints (dunno which ones you're using).
And second, as I said how I animate my physical ragdoll (it's called active ragdoll if I'm not mistaken), imagine my character is lying on bed, and physboxes for arms/torso/legs are larger than actual mesh geometry, so when character is laying on bed, these physboxes would go inside of a bed and try to jump out violently. What can I do about that, so that things don't jump from static bodies/other rigid bodies when they intersect?
I don't know how to tune the penetration resolution logic, which causes the sudden pops. Usually best to avoid penetration in the first place (which is what shorter substeps can help with) and also avoid transporting objects by slamming their transforms... if you can. Dynamic objects should be pushed into place by adding force, adding impulse, or slamming velocity. Moving kinematic objects should have their transforms updated AND their velocities set to agree with their motion. Setting a kinematic object's velocity doesn't actually move it (kinematic objects are not integrated forward by Bullet), but the velocity is used by the collision events to properly resolve collisions with dynamic objects and when kinematic objects' velocities are correct the simulation will experience fewer penetrations.
Post Reply