Ledge Grab system p2 — Ledge Check

Kinga Osińska
3 min readAug 19, 2021

In this article, we need to figure out when we want our character to throw his hand out to grab the ledge.

First, we need to go to the Playmode and see when we want our Character to grab the ledge.

Create a new cube and call it Ledge_Check. This GameObject will collide with our Ledge_Grab_Checker and we will snap to the position of hanging on the ledge. Set the Trigger to true, so our player won’t bounce off of it.

Next thing we will do is trigger the Ledge Grab system. Our Player will jump, we will detect the ledge grab, we will trigger the animation, and disable gravity.

Add a Rigidbody to Ledge_Grab_Checker that is attached to our Player. Change the Use Gravity to false, and set isTrigger to true in Box Collider component. Change the tag to Ledge_Grab_Checker. Also, disable the Mesh Renderer on this GameObject.

Create a Ledge script and add it to Ledge_Checker. Add OnTriggerEnter() method. We will check if the GameObject colliding is the Player. If it is, we will call a method we will create in Player script that will disable character Controller to disable gravity.

Create a new method called GrabLedge() in the Player script, and called that method int he Ledge script.

In the LedgeGrab() method we will disable Character Controller component to disable gravity.

Now we need to transition to Hanging Idle animation. To do that we will use a Bool parameter. We will transition from Running Jump to Hanging Idle.

Also in the transition from Running Jump to Idle, add another condition.

--

--