This is totally possible using only Blueprint, and you won’t have to touch C++ at all. Sadly that is all the assistance that I can provide at the moment. If your question is still unanswered after a while, then I’ll try to create a sample Blueprint for you.
I read in another thread that UE4 doesn’t have ladder volumes: How do I create a Ladder Volume? - Programming & Scripting - Epic Developer Community Forums
I’m guessing I can make a ladder with Blueprint? I started by creating a volume with a mesh that when the player overlaps their location is modified so they’re basically teleported upward. That’s the first iteration.
The next step would be to instead change the player controller to one that made forward = up and backward = down perhaps? And probably turn off gravity while in that volume? And maybe change the player state to “climbing”.
How much of this can I do with Blueprint and what parts would definitely require C++? Any clues on which classes or functions to look at, either in the code or via Blueprint, would be appreciated!
Hi, I’m sorry for hijacking this answer, but I’m also looking for a ladder blueprint example to be used with the platformer template. Can you please provide the sample blueprint? I would be very grateful. Thank you!
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!
I’ve uploaded a quick Blueprint. I hope it helps!
Thanks for taking the time to make/upload this and write up an explanation.
You’re welcome! I hope it has helped!
Thanks for taking the time Parralex!
Turns out the answer had been accepted by an admin before I could even check it out, but I’ve managed to give it my own tick off approval now, thanks again
You’re welcome! Let me know if you need help with anything else!
I may be over-simplifying this somewhat, but thought I would post my solution for ladders here just in case anyone finds it useful. It is extremely simple and quick to set up, and produces exactly the behavior that I wanted. (Though others may want more for their games)
First I created a simple ladder blueprint and in the components tab made the ladder out of meshes in the example content:
Note: make sure that the ladder volume (box component) extends far enough above the ladder mesh to allow the player to step off once reaching the top.
Next create this graph in the ladder blueprint graph tab. It simply sets the players movement mode to flying when entering the volume, and walking when exiting it. (Walking works better than falling as it ensures that the transition at the top looks natural)
Final step in next post since it only allows 2 attachments per response.
Finally, in the player blueprint, I check if the players movement mode is swimming or flying, and if it is either I add the pitch value into the movement calculations so that up and down movement work, otherwise i use the default “yaw only” calculation from the 3rd person sample.
This produces a ladder volume that you can climb up and down and even move sideways on but as soon as you exit the volume you immediately transition to walking (which works well at the top and turns into falling if you are jumping off of the ladder midway.
I will of course be adding in custom animations for it as well as some special input handling for actually jumping off of the ladder midway.
Your layout is very similar to mine! I think the only difference is I have it set up to add movement to the z axis based on a key press (f for mine) instead of based on pitch. Amazing work!
Parralex may you publish sample scene with you blueprint sample?
I am working on a project that involves ladders/wall walking, and, while I am sure your method above works (im sure it does), the screenshot of your “mycharacter” BP is not high-rez enough for me to see what is going on =( By chance, can you break up your screenshot into 2 or 3 parts, or, make your BP available for download?
Again, your the man for answering this question! Just having trouble following your BP screenshot…
Just reorganized this a bit.
If you want, i can try to recreate the middle Part of his screenshot for you. I can see everything clear (:
Thank you ! I was able to combine the two screenshots into one image, and, from what I can tell, my character is walking up ladders/walls now =D Thanks again!
PS. For anyone who needs the combined image, please see attached.
I got it to work when I mixed Parralex solution with
Hi smokeBONES, could you post the PDF file to a dropbox or could I get a copy of the pdf file. Thanks
Hey guys tanks for the hd transcript,
Only one thing missing for those of you who tumbled on this remake and wonder why its not working properly.
You need a GET FORWARD VECTOR for your move forward INPUT and a GET RIGHT VECTOR for the right input ( swimming and flying) . I was grinding my head on this for a little while till i checked the actual not hd post to figure it out. now works like a charm. THANK you all who worked to make this possible!