Jump with Friends 2d Game and Unity Physics

Small 2D puzzle game level.

We had to make a concept and advertise it in 2 days, so I came up with the idea to make one level of our idea and make a trailer out of that.

This level works like this. You play with 2, the gravity of 1 player is reversed, both need to reach the middle and enter through the doors. You can manage this by changing the gravity of the objects on your side, to make a bridge for the other player to jump on. Let me show you how it’s made.

As you can see here I made a reverse gravity by giving player 2 a constant velocity upwards, it represented the gravity it was supposed to have if it was reversed. Together with the two ways of jumping for each player.

Here is the script for the crates you saw on the GIF. It works the same way as the player script for the purpose of reversing gravity, but I found a problem. When a crate was going too fast it wouldn’t collide correctly and so the crates would just go through each other, unable to stack them. I made a workaround that was not perfect, but it did the job, using a IEnumerator to freeze the object when it collides with another crate.

Here you have the raycasts for each player, it’s a bit messy but it did the job good enough for the trailer. When a player presses the E button near a crate it would reverse the gravity of the crate, making it possible for the player to go through the level by making stacking the crates.