- Home /
Flat 2D bounce against gravity?
When I use the 2D physics bounce material, if my object doesn't land perfectly flat, it ends up bouncing like a ball - it spins and flies off to the side. What i want my object to do is act like a doodle jumper, and just pop straight up again without rotating or spinning. How would I do that? If the answer comes in script format I would prefer C#, but JS is fine so long as it doesn't mess anything up.
Answer by kacyesp · Sep 07, 2014 at 07:07 AM
Don't use Unity's built in physics, and write a script to control the physics of your object.
Answer by Pyrian · Sep 07, 2014 at 03:34 PM
You could set the Rigidbody2D to fixed angle, then it won't rotate.
That works, but it still has the force applied in a random direction. That means it will constantly move in that direction until the force is changed.
void OnCollisionEnter2D(Collision2D coll) {
if (coll.gameObject.tag == "Enemy") {
Debug.Log ("hello");
rigidbody2D.AddForce (Vector3.up * 400);
This works fine now.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Can anyone tell me what I'm doing wrong here? 1 Answer
Distribute terrain in zones 3 Answers
Jump and run on a circle (2D) 0 Answers