2.2 Installation
This guide walks through setting up the Ledge System in your Unity project for the LedgeAgent_Sample_Character provided in this package as an example. In later chapters, we'll guide you to create your own customized ledge agent.
Scene Setup
To begin using the system:
- Add the
LedgeAgent_Sample_Characterprefab to the scene. - Add the
CameraRigprefab to the scene (remove the existing camera). - In the
LedgeAgent_Sample_Characterprefab'sPlayerControllerscript, setCameraTransformtoCameraRig. - In the
CameraRigprefab'sCameraControllerscript, set thePlayerfield toLedgeAgent_Sample_Character. - In
PlayerController, setGroundLayerto any layer you want your player to walk on. - Add your ledge geometry to the scene and set it to a layer (see the Layer Configuration section below).
- Start the game and test the ledge detection.
Layer Configuration
This system identifies ledges primarily by layer — an object must be on the correct layer to be detected as a ledge.
- Locate the
LedgeDetectionDataandLedgeAgentDataassets. - In
LedgeDetectionData, set theGrab Layermask to any layers you want recognized as ledges (for example: Ledge, Platform). - In
LedgeDetectionData, set theClimb Layermask to any layers the player should be able to climb onto (for example: Ledge, Platform, World, Default). - In
LedgeAgentData, set theObstacle Layermask to any layers that should block climbing or jumping. This isn't required, but it's recommended for the examples to work as intended. - Make sure to assign the same layers to your scene objects.
Verifying Setup
Enter Play mode and test:
- Approach a ledge while airborne.
- The system should detect a valid ledge.
- The player should snap into position.
- The player should be able to move left and right, climb, jump up, jump away, and drop.
If nothing happens:
- Check
LayerMasksettings. - Verify colliders exist.
- Ensure the player is not grounded.
- If you're using your own custom player controller, see the next page for guidance on setting up your own player game object.