- Home /
Object should be bouncier
I'm building a 2D platform game. In one of the modes, if you hold the mouse button and approach a GameObject that has a collider attached to it, a collision occurs. I achieve this by placing, while the mouse button is being held, a game object with a sphere collider where the mouse cursor is.
I'd like to achieve a bouncy effect, so that I can guide an object that would bounce on the cursor until it reaches a given goal. The gravity is set very low to allow time for reaction.
The thing is, the object I'd like to guide only bounces when I approach it as it is lying on the ground. Once it's airborne, the cursor's collider holds it in the air, but there is no bounce to the collision.
I've tried by adding an hyper-bouncy physics material to both colliders, to no avail. I also read about the problem with skin widths, but as far as I understand it, that's only an issue for character controllers.
Perhaps this is all a little fuzzy, but do you have any idea what could be preventing my object from behaving more "bouncily"?
I just realized that with the Physics $$anonymous$$aterial added, the object bounces against other objects, just not against the collider I manipulate with the mouse. Still a problem.
Answer by Justin Warner · Apr 19, 2011 at 04:32 PM
Can you put on a physics material? I'm not really following what you're saying, but it sounds like you can use the Rubber or a custom physics material: http://unity3d.com/support/documentation/Components/class-PhysicMaterial.html
Hope this helps!
I did! actually, I just edited the original question to explain just that.
Ahhh, I see what you mean, was trying to understand... Alright... Thought about it... Can you do something with like, get the point of contact/collision, and from there actually add a force to the object? Then it'll "push" the object? http://unity3d.com/support/documentation/ScriptReference/Collider.OnCollisionEnter.html $$anonymous$$ight help... This is the only way I can think of.http://unity3d.com/support/documentation/ScriptReference/Rigidbody.AddForce.html
What puzzles me is that, if I wait until the object is lying on the ground and then I approach it, THEN it works. The object shoots in the air like crazy...
$$anonymous$$aybe it's related to the fact that, if I approach the object from below, it's been colliding with the ground, which is an object with a collider (but no rigidbody), then it leaves the ground and immediately meets the object, and collides with it in an irregular way?
The addforce statement sort of worked, although the gameobjct becames all jittery after every collision. I'm creating a new question with that problem and giving your answer my O$$anonymous$$. Thanks!
Answer by oquendo · Apr 22, 2011 at 09:15 AM
A piece of advice for anyone trying to achieve similar results. A few days after this thread I found out about AddExplosionForce, which may work better than AddForce in some cases (it did in mine).
Your answer
