- Home /
Problem is not reproducible or outdated
Collision grazing edges.
I'm doing what is essentially a breakout clone, and I found one issue that is really annoying me.
If the ball grazes a block at the edge, it counts as a collision and will destroy it, but the ball won't bounce off it at all.
The obvious solution was to detect the collision's contact normal and throw the ball in that direction but that had absolutely no effect.
rigidBodyReference.velocity = Vector3.Reflect(rigidBodyReference.velocity.normalized, collision.GetContact(0).normal) * currentSpeed;
Edit:
I guess it's simply a limitation due to physics inaccuracies, doesn't matter what I do I can't seem to correct it.
Answer by lgarczyn · Nov 29, 2019 at 07:59 PM
If there is a collision event, and the physics material has a bounce factor, it means there was a bounce, even if you can't spot it.
If you want the ball not to break the brick on grazing hits, check the angle between the relative velocity and the normal.
If you want the ball not to break the brick on any weak hit, simply compare the impulse magnitude divided by Time.fixedDeltaTime to some arbitrary cutoff point.
I'm fine with the ball breaking the brick on grazing hits, what is bothering me is that it's not reacting to the collision by bouncing off, it just keeps going straight. I'll see if not allowing it to break a brick in those situations is a good option. Although ideally I'd like to just throw it in the direction of the collision normal, feels more intuitive I think.
You should probably post a a video of what you are complaining about, because when a ball's trajectory is close to parallel to the wall, the bounce should we be nearly unnoticeable.