Skip to main content

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 SampleCharacter prefab to the scene.
  • Add The CameraRig prefab to the scene (remove existing camera).
  • In SampleCharacter, PlayerController script set CameraTransform to CameraRig.
  • In CameraRig prefab, CameraController script set SampleCharacter to Player.
  • Make sure you set the GroundLayer in PlayerController to 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.

  1. Look for files : LedgeDetectionData and LedgeAgentData
  2. In LedgeDetectionData set the layer mask for Grab Layer to anything you want to be recognized as a ledge (example: Ledge, Platform, etc.)
  3. In LedgeDetectionData set the layer mask for Climb Layer to anything you want the player character to climb on to when climbing a ledge (example: Ledge, Platform, World, Default, etc.)
  4. In LedgeAgentData set the layer mask for Obstacle Layer to 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)
  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 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.