- Home /
Physics objects bouncing when bounce is 0!!
I created this project to illustrate a fairly sizeable problem with Unity Physics - that bounce cannot be eliminated from collisions...
http://dl.dropbox.com/u/1164739/WeirdPhysics.zip
I've zeroed Bounce - Multiplier is "Min" - I've played with Friction and Bounce Threshold - I've even tried an OnCollisionEnter Trigger to zero velocity and the boxes STILL BOUNCE!!
At this point I'm just assuming Unity's physics is junk - there are similar problems posted here but I'll leave this with the example in the hope that one day they might fix it??
If anyone has any ideas, please post em!
Note: I resolved the initial collision issue (ensuring objects were at least 1 unit in all 3 dimensions did this) so I've amended the question to just cover the bounce issue - which I'm fairly sure no-one will have a clue how to solve! :)
Answer by rabbitfang · Feb 17, 2012 at 02:17 AM
From a physics engine standpoint, what is probably happening is that the bouncing object penetrates the other object and is pushed back out. When it is pushed back out, a velocity or force is applied to give a more realistic physics simulation (even without bounce). (Normal force of the contacting surfaces).
One thing that you might try to do is to set the velocity of the bouncing object to zero in the direction of the collision normal so it isn't coming back at you.
I'd tried fiddling with the 'Penetration' values and I think you're right because some boxes bounce a LOT more than others (not necessarily related to their velocity either!) - but adjusting their velocity in the collision doesn't seem to work (I assume the 'shove' it gives is being done AFTER the collision triggers are firing?)
$$anonymous$$y other idea was to make them kinematic, 'shove' them downwards, and when I detect a collision, zero velocity and position them 'stacked' above the thing they hit (they can also disable physics on the thing they hit which reduces the amount of colliders which have to be dealt with) but it's proving 'harder than it sounds!!'
I would guess that it is. $$anonymous$$odifying physics engine behavior like this is fairly annoying and it is likely that an update to the engine might cause your change to break. Which is why it is technically a 'hack'. You could try implementing Rigidbody yourself with modified behavior.
A bit more digging suggests the problem isn't penetration - it's something to do with transmitted forces...
If a block hits another block - both of which have no bounce - they won't bounce. However, if a block hits another block which is touching another block (and so on) it seems forces are transferred through all of those objects - and even if they are all 'bounce zero' - they bounce.
Simple 2-body collisions seem to be O$$anonymous$$ but the moment you have a collection of objects, things start to go awry...
$$anonymous$$aybe setting rigidBody.maxDepenetrationVelocity = 1 will help. See https://answers.unity.com/questions/58689/bounciness-0-still-bouncing.html?childToView=1742680#comment-1742680
Answer by uanmanarmy · Jul 31, 2014 at 10:31 AM
Put this code onto your objects #pragma strict
function FixedUpdate()
{
var currentVelocity = rigidbody.velocity;
if (currentVelocity.y <= 0f)
return;
currentVelocity.y = 0f;
rigidbody.velocity = currentVelocity;
}
Your answer
Follow this Question
Related Questions
Avoid bouncing when ground move down 1 Answer
Enemy bouncing physics 0 Answers
Object with rigidbody bounces after hit. 0 Answers
make object rotate towards its direction after bounce 1 Answer