- Home /
Animated mesh collider
I have an animated mesh that I need to hit a ball. It does hit it, but even though the physics material on the animated mesh is set to rubber it doesn't bounce. It actually kills all the momentum and just rolls slowly away. I've tried every setting I can think of but no luck. Any ideas?
I would think you would want the ball to have a rubbery material and the mesh (a bat?) to have a very solid material. Are you moving the animated mesh manually or letting the kinetics drive it's interaction with the ball? If you let Unity handle the response between the two objects, you might see the animated mesh flying away when it hits the ball. $$anonymous$$ake sure, to avoid that, that the ball mass is way way smaller than the animated mesh's mass.
it's a flipper and a pinball, so I have the flipper be rubby and the ball be metal. The flipper has an animation that plays when you hit the button. The many physics settings I use are "Convex" on the mesh collider for the flipper. Animate Physics on the animator of the flipper. "Is $$anonymous$$inematic" on the flipper and "Interpolate" and "Continuous Dynamic" on both the flipper and the ball. Hopefully that makes it clearer.^^
That is more clear, yes in this case it makes more sense the way you have it. I think this is a problem in that the flipper might be moving too fast, so the surface of the ball falls beneath the surface of the flipper on several frames. The easy solution is to add an OnCollisionEnter method to the flipper, then call AddForce() on the ball that is passed into that method. You are essentially simulating what the flipper would do, add force, but the physics engine can't estimate due to its discreet nature (even with continuous selected). You can also increase the amount of bounce of the ball by setting the flipper physic material to $$anonymous$$aximum for the bounce Combine value. You might even use the collider's AddExplosionForce method to add some spice to it.
A couple of other things. If you have issues with the ball falling through the flipper, you can increase the physics time steps by reducing the Fixed Timestep value in Project Settings ->Time. Obviously, depending on the hardware you publish to, this time may not be feasible if you make it too small. Additionally, you can increase the bounce effect by reducing the value for Bounce Threshold under. Project Settings->Physics. Lastly, I would suggest if possible to use a box collider for the flipper. Since the bottom of the flipper is less important, it probably won't matter to the player if the ball is hit just slightly out of sync when the ball is on the underside. Convex physics tests will be more time consu$$anonymous$$g.