Implementing moving platforms
While the level structure is complete, they are relatively static environments. The only moving element is that of the player. We'll rectify this situation by creating a moving platform. The platform should move up and down continuously, and the player should be able to jump on it anytime to hitch a ride. We'll construct the object as a prefab so that it can be reused across multiple scenes. See Figure 6.19Â for the result:
Now that we have an idea of the end goal, let's start by creating the platform GameObject.
Creating the platform object
To create the platform object, take the following steps:
- Select the Platform texture in the Project panel.Â
- Select the Sprite (2D and UI) Texture Type option in the Inspector:
- Set Sprite Mode to Single.Â
- Drag and drop the Platform...