I apologize for the late reply!
Here is a quick demo blueprint that can function as a ladder.
I’ll explain it step-by-step.
This is running within the player Blueprint. Upon each “Event Tick” (meaning that it runs every frame), a line trace (also known as a raycast) is cast from the player’s position to wherever the player is looking. You can see this as “Get Actor Location” is connected to the trace’s “Start” input. To make a line cast in the direction that the player is looking, I first grab a reference to the camera that is attached to the player (I’m using the First Person Blueprint Template by the way). Next, I remove the Pitch and Roll information from the Rotator so that the line is cast parallel to the ground (Yaw deals with the X and Y axes, Pitch deals with the Z axis, and Roll is the rotation around the forward vector; if you want to include the Pitch, then the “Break Rot” is unnecessary, although the “Start” input will need to be changed to the Camera’s location instead of the Pawn’s). “Rotate Vector” effectively converts the Rotator into a Vector, which is then multiplied by 1000, which acts as the length of the raycast. By adding the player’s location to the trace, it localizes the “End” to be relative to the player. “Make Array” is there to check for WorldStatic objects, which I assume your ladder will be (moving ladders would be a bit more complicated).
In my scene, I placed a Blueprint Actor that I made that consisted of a StaticMesh that represented the Ladder. In that Blueprint, I set the StaticMesh to be Static (not Stationary or Movable) and in the Defaults tab, I added “Ladder” as a Tag Element (without the quotations).
Back in the player Blueprint, I have a Branch that checks for 1) whether anything was hit, 2) whether the actor that was hit has the “Ladder” Tag (which effectively verifies that the ladder is being looked at, and also allows any object that has a “Ladder” tag to be used as a ladder), and 3) that the player is in a “Falling” state. This prevents the ladder from being activated by simply being close, and requires the player to ‘jump’ onto the ladder. When all three of these conditions are met, then we move on to the next part, else we reset the gravity back to normal (it hasn’t changed yet, but it will during climbing). Next, we check how far from the ladder we are, so that it is only activated when we are close enough. To do this, we grab the “Impact Point” and subtract the player’s position from it. The length of the resulting vector is then checked to see if the length is small enough (I have it set at 100 in the Blueprint, but you can set it to any value you want, just remember not to set it too small, else it won’t make it past the character’s bounds).
If it is, then we move on to the next step, else we reset the gravity.
Next, we check to see whether the player is trying to move the player forward, back, or at all. If they’re trying to move forward, we convert this movement into positive movement along the Z axis (which moves the player up; I have it set to 500, but you can increase or decrease the speed as you see fit, or make it variable depending on how close to 1 the “Return Value” of MoveForward is). If the player is not trying to move forward, then we check if they’re trying to move backward. If so, we set the movement as negative along the Z axis. If the player is doing neither, then we nullify all movement, so that the player stays at their current position. After these steps, we set the gravity to zero, so that the player does not continuously fall when not moving.
This being a quick blueprint that I made, there are quite a few inefficiencies from an optimization standpoint, such as setting the gravity to zero during every frame that the player is on the ladder, and resetting the gravity whenever the player is not on the ladder (which will most likely be the majority of the time). In addition, this blueprint does not handle what to do once the player has reached the top of the ladder. Currently, they will bounce up and down, as once they go over the StaticMesh, gravity will take hold, which will cause them to fall, and reattach to the ladder. An easy way to “pull up from the ladder” would be to have a trigger volume near the top of the ladder that activates when the player enters it, and a timeline that plays that moves the player to the top of the ladder.
I hope I explained everything clearly! I apologize if my grammar is messy in a few places. I’ll be happy to answer any further questions that you may have!