Installation
This guide walks through setting up the Ledge System in your Unity project For the SampleCharacter 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
SampleCharacterprefab to the scene. - Add The
CameraRigprefab to the scene (remove existing camera). - In
SampleCharacter,PlayerControllerscript setCameraTransformtoCameraRig. - In
CameraRigprefab,CameraControllerscript setSampleCharactertoPlayer. - Make sure you set the
GroundLayerinPlayerControllerto anything you want your player to walk on. - Add Your ledge geometry to the scene and set them to a layer (look at Layer Configuration section).
- Start the game and try to do ledge detection.
Layer Configuration
The main identifier of a ledge for this system is the layer to be considered a ledge.
- Look for files :
LedgeDetectionDataand LedgeAgentData - In
LedgeDetectionDataset the layer mask forGrab Layerto anything you want to be recognized as a ledge (example: Ledge, Platform, etc.) - In
LedgeDetectionDataset the layer mask forClimb Layerto anything you want the player character to climb on to when climbing a ledge (example: Ledge, Platform, World, Default, etc.) - In
LedgeAgentDataset the layer mask forObstacle Layerto anything you want to be regarded as an obstacle that prevents climb or jump (This is not necessary but is recommended for the examples to work perfectly 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 are using your own custom player controller system, you might want to go to the next page where we guide you on how to setup your own player game object.