- Home /
Colliding rigid bodies fly upwards
Hey
I'm using the input of the mouse to throw around a gameobject (player) which collides with other gameobjects (enemy). Sometimes when there is a collision the enemies fly upwards. I've tried increasing the mass of the enemies but thats not helping.
i'm using the following line to add an Impulse force to the player (the moving of the mouse is the input)
rigidbody.AddForce(new Vector3(input.x * multiplier, multiplier / 3, input.y * multiplier), ForceMode.Impulse);
any ideas why the enemies get thrown in the air? is this because there colliders are a little bit from the ground and the collision happens beneath it? how would i make sure the upwards force on the enemies isn't to big?
What deter$$anonymous$$es the multiplier? Is it a constant positive number? If so, then wouldn't "multiplier / 3" in the y-axis give you some upward force everytime?
multiplier is a constant number. this is an AddForce applied to the player, so it gets lift of the ground a little bit so i can throw the player around. The problem is when it hits the enemy, they sometimes fly in the air. so i don't know how to get the enemies mass high enough so it wouldn't do that.
aha i forgot about the material on my collider. i created a new one for the enemies (was using the same as the player) and increased the friction. This seems to be going in the right direction)
If you solved the problem then go ahead and write it as an answer or close the question.
yeah i'll do that, thx for taking your time in helping me. Typical, i've been breaking my head what would help. Then i finally ask a question and i find the answer :p
Answer by ikno · Nov 18, 2014 at 09:26 PM
I was using the same physics material on my player and enemy gameobject. I created a new physics material and put in a larger dynamic friction (player was on 7, enemy set to 70) which fixed this problem. Now i just have to find a good #friction.
Answer by BradLeeD · Mar 26, 2018 at 10:36 PM
I have found a great answer to this problem - in 1 specific occurrence at least.
My Ex:
I had some cubes that ran back and forth - and when the player (cube) collided with them - they would stop and slowly push on the player though.. - Anyway.. this worked fine until one day it started BOUNCING my player up into the sky out of NOWHERE!!! D : I tried several fixes - only to realize - that my Plane (floor) underneath the cubes had accidentally gotten moved up a few world units (in the z axis) - SOOOO... - now my plane was intersecting with my running cube objects - .. I moved the plane back down - and low and behold .. the problem went away. - so watch out for GROUND and surrounding object's intersecting with your objects that have rigidbodys at start because this can cause a LOT of bad problems. Hope this helps some ppl! : ) Happy GameMaking!
Your answer
Follow this Question
Related Questions
The force on a collider which is penetrating the other collider 1 Answer
How to make the collision force to effect on one object? 1 Answer
Object thrusted violently in opposite direction on collision 1 Answer
Breakout clone. 1 Answer
How do I apply a force to the other object in a collision? 1 Answer