My journey becoming a Unity game developer: 2.5D Infinite Runner-Prototyping
Objective: Setup a Player, basic level, and a pick-up by using a prototype for the game.
We’re going to create an infinite runner game where the player will be able to jump from one platform to another, push an object out of its way, and grab onto a ledge and pull themself up.
Let’s begin with creating a Cube game object and name it Platform. Set the Transform positions to zero, and Scale the X-axis to 5 which will make the platform a little longer. Last, create a Prefabs folder inside the Assets folder and drag the Platform game object into the Prefabs folder.
With the Platform still selected, duplicate the platform to create multiple platforms and make sure the Transform Position.Z equals zero to keep the platforms on the same layer. Position them with one platform high enough for a double-jump. Plus, have another platform low enough where the player needs to jump back up to the main level. The last platform is going to move between the top and bottom platforms, then back and forth from the platform to another location. If you want to see the platforms in the Game View Tab, click on the Main Camera, adjust to the view you prefer in the Scene View, and use CTRL-SHIFT-F to Align to Scene View.
To keep these platforms organized, create an Empty game object and name it Environment which will hold all game objects in the scene the player will have to navigate through. Select all the platforms in the scene, and drag them into the Environment object.
Next, create the Player using a Sphere 3D game object. Make sure to set the Transform position on the Z-axis to zero. Add a Rigidbody component with the Use Gravity turned on to the Player. Move the Player above the 1st platform to set its starting position.
As we see, the Player will fall down onto the 1st platform because Use Gravity is turned on. However, we will not be using the Rigidbody component on the Player as we will control gravity through our script. Therefore, make sure to remove the Rigidbody component from the Player.
Finally, create pick-up game objects for the player by using the Sphere 3D game object and name it Collectable. Set the Transform Position.Z to zero to keep it on the same layer as the other game objects. Add a Rigidbody component to it, and turn off the Use Gravity setting. Also, make sure the Sphere Collider’s Is Trigger is turned on to allow the player to go through the pick-up objects.
Next time we will create a Physics Based Character Controller through our script.