Journal 83 — Unity 2.5D Platformer, Add Modular Platforms
Objective: Make the ledge grab and climbing platforms modular
In the previous series of articles, we have created a basic platformer layout with a 3D character, assets, and animations. In the last article, we created a ledge grab and climb up animation for a single platform. In this article, we will expand on the basic game features. We want to now make this platform modular, so we can duplicate it, and the same jump, ledge grab, and climb up animations all work.
As you can see in the Scene view and Inspector, the platform currently uses a set of coordinates for the location where the player grabs the ledge, and a set of coordinates for the standing position once the player climbs up the ledge.
To address this, let’s try making an empty game object at these two locations, and reference those in the ledge script.
We can start with creating two empty game objects in the main hierarchy, and assign them the coordinates in the Ledge script. Note these are global coordinates. Once you have created these two objects, drag them under the Ledge_Checker game object as children. Then they will take on local coordinates in reference to the collider.
We can update the Ledge and Player script with the two game object references.
Here are the results. The ledge grab and climbing system still work, same as the previous function with coordinates.
Now, we can try making this edge platform into a prefab and duplicating it and try another ledge grab and climb up sequence.
Here are the results. It works!
Thank you for your time!