Ledge Grab System Part III

Intro

In this short article, we clean up the ledge grab by snapping the position of the player to certain spot when the ledge grab is triggered.

Setup

Move the player to find the position where it looks like the player is grabbing the ledge. Write the X ,Y & Z coordinates down for the code.

The Code

In the Ledge script, we are going to create a Vector3 variable that will hold the position of the hands we want when the ledge grab is triggered. We want to give it a serialized field attribute, so we can place the X,Y & Z coordinates we wrote down from before.

In the Inspector, we will input those coordinates.

When we call the GrabLedge method from the Player, we are going to pass in Vector3 parameter that will be our hand position.

In the Player script, looking at the GrabLedge method we will create a Vector3 parameter call it handPos. We will set the Players transform.position to the Vector3 position it is receiving from the Ledge script.

Conclusion

This was a short article and was heavy on coding, but the result of this position snapping makes for a much smoother transition from jumping to grabbing. Until next time…Cheers!

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

8 Tech Events Presented by Tokopedia Academy

WORDPRESS .ORG VS WORDPRESS .COM

the difference between wordpress .org and .com

Codechef ATM Problem Solve in Python

Four Layers of Digital Asset Management

My Experiences as a Software Developer in a Ghanaian Software Startup.

Mest Incubator for Software Startups, Accra

Weeknote: 9 July 2021

“Frontend Developers Aren’t Real Developers”

Frontend developers aren’t real developers

A 4-Item Cloud Migration Checklist For Small Businesses

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ryan McCoach

Ryan McCoach

More from Medium

Virtual Cameras w/ Cinemachine in Unity 2020 — Part 5

Modeling An Elevator Console With Unity ProBuilder

Day 103: Creating A Ledge Grab in Unity Part 1

Instantiate and Destroying game objects in Unity