Skip to main content

2.2 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 the SampleCharacter prefab to the scene.
  • Add the CameraRig prefab to the scene (remove the existing camera).
  • In the SampleCharacter prefab's PlayerController script, set CameraTransform to CameraRig.
  • In the CameraRig prefab's CameraController script, set the Player field to SampleCharacter.
  • In PlayerController, set GroundLayer to 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.

  1. Locate the LedgeDetectionData and LedgeAgentData assets.
  2. In LedgeDetectionData, set the Grab Layer mask to any layers you want recognized as ledges (for example: Ledge, Platform).
  3. In LedgeDetectionData, set the Climb Layer mask to any layers the player should be able to climb onto (for example: Ledge, Platform, World, Default).
  4. In LedgeAgentData, set the Obstacle Layer mask to any layers that should block climbing or jumping. This isn't required, but it's recommended for the examples to work as intended.
  5. 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 LayerMask settings.
  • 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.