19-03-2021, 01:35 PM
(This post was last modified: 19-03-2021, 01:43 PM by josemendez.)
Hi,
I made you an example of this. You can find it attached (it's a zipped UnityPackage).
As you will see, it's very simple: a surface shader that deforms the mesh in the Y direction, and a C# script (BounceController.cs) that drives the amount of deformation using a spring. That's it.
You can call the bounce controller's AddImpulse() method whenever the ball touches the ring, and you're done. You could even pass a larger or smaller impulse depending on the contact velocity.
This is how it looks like (an impulse is added every time I press the spacebar, making the ring "bounce"). Different values for the spring and the dampening coefficient give different results:
cheers,
I made you an example of this. You can find it attached (it's a zipped UnityPackage).
As you will see, it's very simple: a surface shader that deforms the mesh in the Y direction, and a C# script (BounceController.cs) that drives the amount of deformation using a spring. That's it.
You can call the bounce controller's AddImpulse() method whenever the ball touches the ring, and you're done. You could even pass a larger or smaller impulse depending on the contact velocity.
This is how it looks like (an impulse is added every time I press the spacebar, making the ring "bounce"). Different values for the spring and the dampening coefficient give different results:
cheers,