5 Minute DOODLE JUMP Unity Tutorial




Doodle Jump was one of the first mobile games to reach wide spread popularity, and was a massive success. Learn how to make the basics in this 5 minute unity tutorial.

Pro Tip: If its too fast, play the video on .5 speed and pause often!

This was tough to edit down, sorry 😅

➤LIKE the video if you enjoyed, it really helps the channel!

➤SUBSCRIBE to the channel, you’ll make me happy

➤MORE 5 Minute Tutorials: https://www.youtube.com/playlist?list=PLhrayuv80FeVbdfce8bQLwe-GxXf6LGtZ

➤Join our DISCORD SERVER: https://discord.gg/pMrMshh
We have channels to help you with your problems!

0:00 Background Image

I googled around for the Doodle Jump assets, and was able to find the Background, Player sprite, and platform sprite. USE ANY ART ASSETS YOU WANT!

With the background we simply just add it to the scene, reset its transform, and then attach it as a child gameObject to the Main Camera. This makes it so the background will always follow the camera.

0:017 Player Setup

We drag in a player sprite, and then we attach a BoxCollider2D. Using the edit collider button, we can then drag in the edges of the BoxCollider so that we’re only detecting collisions around the base of the sprite. This may vary depending on the player sprite you’re using. We don’t want the collider to be too small or you may have errors when calculating collisions, so leave a bit of a buffer.

We then attach a Rigidbody2D, and set the Collision Detection mode from « Discrete » to « Continuous ». This provides us with a cleaner detection algorithm at the expensive of processing power, but in this case where precision is important it’s worth it.

We then want to add a Constraint to freeze the rotation in the Z axis, so that our sprite won’t rotate on its own and mess up the movement code.

Finally we create a new C# script, PlayerController and add it to the player GameObject.

1:05 Platform Setup

We drag in a platform sprite, and for the platform we want the player to be able to pass through the bottom of a platform, but detect collisions from the top. To do this we need to add an EdgeCollider2D component, and then we also add a Platform Effector 2D component.

On our EdgeCollider2D we want to enable « Used By Effector », and on our Platform Effector 2D we want to make sure « Use One Way » is checked, it should be by default.

With that, you should see a 180 degree arc coming from the top of the platform, which means it will only detect collisions within that arc.

Again, we add a new C# script Platform and add it to the platform gameobject.

1:34 Create Camera Script

We create and add a new C# script CameraFollow to the Main Camera

1:40 Create GameManager

We create an empty GameObject, call it GameManager, and then create a new C# script called GameManager to this GameObject.

1:50 Platform Prefab

We then drag our platform GameObject from ther Hierarchy into our Assets folder, which will create a Platform Prefab.

1:59 PlayerController Script

For the Player movement we basically only want to be able to move left and right, and we want to tweak how fast we can move based on a MoveSpeed variable.

To handle movement we need a reference to our Rigidbody2D.

In Update we want to detect any inputs from the player, so we store our « Horizontal » input axis into a private variable.

In FixedUpdate, we want to handle physics calculations within our Rigidbody2D, so using our captured input from Update, we then update our current velocity.

2:52 Platform Script

For our platform script, we want to store a JumpForce float variable we can tweak, and then basically OnCollisionEnter2D we want our player to be launched up by the jump force, but only when our Player is landing from the top, otherwise this could cause issues if we perform the boost when the player is passing through the bottom of the platform.

3:36 CameraFollow Script

We store a Transform target variable to follow. And then in our LateUpdate method, we basically create a new Vector3 using the camera’s X and Z axis, but the Player’s Y axis, and assign this new vector3 to the camera’s position.

We only want to do this when the player has gone above our Camera’s vision, so that we pan the camera up to follow it.

4:14 GameManager Script

On Start we want to procedurally generate a random level. We store how many platforms we want to make, and then in a For loop we create X amount of platforms, always increasing the Y value by a small amount (.5 to 2) and choosing a random X value.

With my settings, when I dragged the platform to the edges of the Game Screen, the values were around -5 and 5, so I used that. You may have to use different values there!

We then instantiate the platforms using the newly created position and the Quaternion.identity rotation.

With all of that done, you can not hit Play, and while there’s still some features lacking, you more or less have the base Doodle Jump game ready to play with and to build from.

Thanks for watching!

#bmo #unity #tutorial

Voir sur youtube

KA2Studio
Logo
Compare items
  • Total (0)
Compare
0