I am working on a mini 2D game, in which there are objects that fall from the sky, at some point I need my player to stand on them as they keep falling to the ground at a constant speed, and thus they can’t be a RigidBody.
The issue is that my player keeps bouncing on them as they fall, never being grounded.
Note: both the player and the object have a physics material with 0 bounciness, and note that I still want my player to have gravity and everything a RigidBody has.
Thank you in advance!
Try adding Physics Material 2d
Play with bounciness values.
Upon collision with an object get a grounded flag on, and when it’s true make your Player match the speed and direction of the falling object maybe. Might be unnecessary once physics material is introduced.
for some reason a physics material with 0 bounce doesn’t work, keep in mind that my player is a RigidBody, and so the problem might be that gravity keeps pulling it downwards and so it keeps bouncing.
Is player itself falling faster than the object’s fall speed?
I really don’t know, how do I check that?
it’s weird because I tried everything I saw on the internet to stop this bouncing thing
I meant, if you drop the player and an object from above at the same time, won’t they fall at the same speed? If the player is clearly falling faster, it’s hard to say much without more information
I’m sorry, I forgot to mention that the objects “falling” from the sky are not really falling, meaning they are not a RigidBody and thus not really falling as a result of gravity, I am using transform.position
because I need them to fall at a constant speed no matter what.
do you think there’s something wrong with this approach?
I think transform.position
should be fine, but you can also try adding a Rigidbody2D to your falling object and setting its Rigidbody2D.velocity in Update()
. This way, the player still won’t affect the object’s fall speed when standing on it, and maybe the player won’t bounce.
If that doesn’t work, then the problem isn’t with using transform.position
to drop the object
I tried this before, it doesn’t work, even though it’s only a frame or two, when the Player collides with the object (rigidBody) it would still act some kind of force upon it, making it move inconsistently.