- Home /
Transferring momentum from one player to another player?
Hello, I am fairly new to Unity and I have a question. I am trying to make a top down 2D game where players collide into each other. I would like for the players when they collide to knock each other back. So my question is how would I go about transferring the momentum of one player to another and is this even the right approach? Thanks!
Answer by AlejandroBoss10 · Jun 10, 2020 at 04:25 AM
I'm not the best when it comes to physics in a game, but I think I might have a solution. Maybe when the players collide, they each get the speed of the other player and then subtract that number from their own speed twice for maybe a second or so.
So let's say, Player1 is at a speed of 10 and Player2 is at a speed of 7. When they collide, Player1's speed becomes the negative of Player2's speed and viceversa for a second or so.
Hopefully this helps.