Squishing a sphere?

Hi,

I’m new to unity and just playing around. I was wondering how I might go about making a sphere squish a little when it bounces (like a football, but a little more “squishy”.

I assume that there’s a script for something exactly like this, or at least very similar, if there is, please point me in the right direction!

Thanks!

I would think an animation might be the easiest. So you do not adjust the collider but the image. I could be wrong tho. To adjust a collider, you need to look at its scale.

Thanks for the reply. From reading up a little it seems as though I should be adjusting the mesh? I might be using terms wrong or just be completely wrong. Which is the correct way of doing it, rather than the easiest?

I am not the guy to be asking, but you could be onto something. Assets like Megafiers handle this quite well I believe. Again, perhaps someone else has a better answer.

I would adjust the Y scale.

it will give the appearance of squishing, it should adjust the collider, and avoids complicate mesh adjustment

(this is how it should work in theory at least)

Dumb question (remember I’m a beginner!), how would I do that?

objectBall.transform.localScale.y = 0.5;

If you want to be sure its going to work as expected, you can do it in the inspector.

You know the top section of a gameobject that allows you to change the position. the 2nd line of boxes is the rotation, the 3rd line is the scale

Hi,

Thanks for your help. I decided to splurge and buy MegaFiers for it’s collision deformation. The only issue is… I can’t get it working! :frowning:

No, sphere collider is unaffected by non-uniform scales, it will always be a perfect sphere.

The reason: Cause of the physics calculations. Two spheres collision are dong by comparing their positions (posA-PosB = distance) and their radius (radiusA+RadiusB). If distance =< (RadiusA+RadiusB) they are colliding. Because of that, a sphere collider can not be squeezed.

@Tseng - How would you approach the real-time animation of a sphere squashing up against a wall?

Animate it, if possible as this is the one with the best performance I can think of (but you can’t change much about collision if they need to be perfect, cause the collider doesn’t get updated on skinned bodies).

Deforming the mesh is more complicated and requires more computing power (deforming mesh + recalculating collider)

It’s simplest, as suggest earlier, to simply adjust the scale. The scale can be interpolated in real-time, based on distance from the collided object, I.e wall or floor.

If you are really looking for a stretch and squash effect then the megafiers system mentioned above is a cracking option, there is even an example of doing a squashing ball, there are videos of that and the stretch part of the system below.