Framework 1: Modular Platforms
Next on our check list is to create an modular platform so once we make it a prefab and duplicate it without the player resetting the ledge grab location. Since we are currently hardcoding the position manually every platform we introduce into the scene we have to reset the position. Instead of hardcoding the position we are going to be using empty transform objects instead.
Scripting the new Modular platforms:
In the Ledge Checker script, we need to change the private vector3 into an Game Object, then on the trigger event we need to also alter the variable when referencing the player script.
Then in the player script we are going to make some small adjustments as well to pass in the new type of data. First change the ledgeClimbComplete variable into a game object type.
Then in the LedgeGrab method, we are also going to update the data type to Game Object.
The same can be done to the public method “ClimbComplete” for pasting the correct standing position via game Object.
Once that is complete, back in Unity, make the two newly created empty game objects a child of the platform if you haven’t already. Then create a prefab out of them. Since the ledge detection is now looking for game objects we don’t have to manually input new variables every time we drag a new prefab into the scene.