I tought this would be for a forum, so i’m posting it here…
Sooo… I’ve got a lot experience with programming itself, buut, i’ve got a problem when it comes to this… It’s not my programming skills, but i just have no idea of how to do this… First of all, the animations are not the problem at all, i’ve got the animations, but i want the controlled character to be able to climb up ledges when you come near them and press a wanted key… I made a system myself, but it is really stupid, just becouse i didn’t have an idea of how to do it… So i made a trigger in front of the ledge, and made it so when you enter the trigger, character’s script checks the trigger’s script, and reads what’s “target” transform (basicly what’s the ledge’s transform), and then you have to stand in the trigger, and press a key, then it just drags the character while playing animation, it just drags it to the ledge’s top, while aiming right at ledge’s x and z cor(ofc i disabled y)… Ofcourse it looks stupid, and example if i had a loong ledge, and if it used just one gameobject, and if i wanted to climb on the end of the ledge, and when i press the key, it would again aim at the gameobjects middle, and not in front of where i wanted to climb up, and would drag it in the same position like before… LIKE NO way, i can’t find a way to make it so the character can climb anywhere, if the ledge’s size is, well, the right size… I need a big help with this one, i’m not asking for codes, but the idea of how would i do this.
I did one of these about a year ago, and my fundamental approach was similar. You just need to do a lot of polish.
For instance, when it comes to positions you don’t want to drag the character to the trigger’s position. You want to somehow work out a new target position and go to that.
When it comes to the movement, you don’t want to just slide. You’ll probably want to pick a transform or two on the character (say, their hands) and translate the whole character such that the hands stay in place throughout the animation until the climbing part is done.
Both of those things involve a solid understanding of 3D math. You’ll need to be able to work out positions/directions relative to both the character and the ledge and be able to transform between the two (ie: work out a position in “ledge space” then convert it to “character space”) and world space. Unity can do the number crunching for you, but you need to understand what the numbers mean and what you can do with them. I think there’s stuff in the Learn section to cover at least a decent chunk of that.
Hmmm, still, mathematicaly, and logicaly at all, how the hell would i know the position of where he should aim at, and where he should be dragged at… Like HOOW. No seriously, like my head cannot get a right idea… I’ve got gameobject ledge’s position, i’ve got my hand’s position, got the animation, but, how… ![]()
EDIT: I will actually draw what i really want to do
Bump i guess ![]()
Very good details here, I could apply this to one of my games. Thanks Ricky!
Hahahhahahaha xD This made me laugh seriously, are you for real ? I HELPED someone without knowing. Or trollin ?
The first step in solving a problem is understanding it. Breaking it down into its constituent pieces helps.
Start here. Describe where the character should aim in relation to the trigger. (You should describe it to whomever may be reading, because that helps a lot, but you’re really describing it it for yourself - look up “Rubber Ducking” to learn why.)
If you’re using triggers and you already have set animations then for each trigger point on a ledge, store the animation that should be used when you are there. Then if you build your levels ledges around which animations you have, then when you play the correct animation to climb a certain height of ledge it should look fine.
But that would limit you a lot, as a small discrepancy in ledge height would then look odd if you use the same animation.
That’s a non “mathy” way to do it.
I use empty objects as postions for steering and movement. Actually, I’m not even sure what the problem is. When the trigger is entered, walk toward empty 0, then start climbing toward empty 1. The nice thing about empties is you can name them the same and use the same script in a prefab, and just move the empties around when you are designing the game. Like I say, have’t used it on a character, just object animations.
Using triggers on the ledges themselves is the most controlled way of doing it, but it does require you to manually set up every single climbable surface.
Depending on the game you’re creating, that’s not a bad thing. You have full control of which areas are accessible this way.
I’ve recently added a clamber feature here, to allow Kerbal characters to clamber onto any ledge, including their ships. Our case required something more self-contained than triggers everywhere, so I came up with a system that works like this:
1- raycast straight downwards in a line just in front and starting slightly above the character. How far this line reaches up is the effective ‘reach’ at which you can grab on to a ledge.
2- if that raycast hits something, raycast again from the character center upwards, to see if there is room overhead to actually climb. This is important to rule out cases where the initial ray might have hit the top of a thin surface overhead.
3- if the second raycast is clear, then we start figuring out where the actual ledge is. We also don’t continue immediately, we show that the climb action is available and wait for player input to climb. We know from #1 that there is a surface just ahead, but where is the edge of it? To find out, we raycast yet again, this time horizontally, starting from the character position towards the hit point from #1, with a very small (0.02 units or so) offset downwards. This is because we’re not trying to hit the first point, we’re trying to hit the very tip of the surface’s edge.
4- That last raycast should not have failed. If it did, we would cancel everything we had so far, but that would probably also indicate something bad like missing colliders. Anyhow, it shouldn’t have failed, and with it now we have information about the location and normal of the ledge we are climbing. Depending on your implementation here, there’s several ways to proceed. What I did was this: From the ledge point, I extract three points. One following the ledge normal, so it’s just in front of the ledge, another just above that one, and finally another just above the ledge itself. These 3 points create a 3-step climbing path over the ledge, and also form a plane which is completely perpendicular to the ledge surface. This is important because you don’t know until the raycast in #3 what the orientation of the ledge was, originally. You may have catched it at an oblique angle, and we want the character to climb facing it. With the ledge normal, we know which way the surface faces.
5- Now that we got all the info we need, the climbing itself is done simply by interpolating the character position to the points, in sequence, and in time with the climbing animation. Rotation is determined by the up vector (determined by gravity) and the ledge normal. Once the third point is reached, we return the character to its idle state so you can continue on your way, after successfully climbing the obstacle.
That’s the way we did it here. Hopefully it’ll be of help to others. ![]()
Cheers
Very, very great reply… I am not gonna do it in the same way, but it created a better ideai n my head
I will post my code of it if i make it out.
Arghhh… This is such a nightmare… I tought i had it, but nope, i’m just confused like never before in my life…
Like, i just can’t… HarvesteR, if you could help me out with code, i would make you a crown, i’d really like it if someone could go through the code with me, i’m so confused and i have such a wierd feeling ![]()
Actually, other thoughts, i didn’t really understand you english-wise… My English skills are not top notch
Yeaah, but still, how…
Just explain to me in English (I can’t help in any other language, unfortunately, but perhaps finding someone in your native language to explain it to would help) this: when the character is standing next to a climbable ledge and starts to climb, where on the ledge should he be aiming?
The reason nobody’s told you what code to write is that learning how to figure that out for yourself is critical to being able to make your own games. It’s pretty hard at first, but with a bit of practice you’ll be rockin’ along in no time. If all you learn is how to follow instructions, though, you’ll never be able to do anything new for yourself.
Oooookaay ? Here’s another picture that will clearly explain what i want to do… Sorry for being annoying, i’m just so frustrated with the thing -

You can’t program a computer by putting pictures in. You need to be able to describe it clearly in words alone.
That picture is still helpful, though. I often approach problems by drawing them in different ways to see what relationships I can figure out. In this case, look at the lines you’ve got there. They’re the basis of this. What is the relationship between the lines and what you want to happen? It might also help to draw in other things you know, like the “forward” vector of the ledge trigger’s transform.
I would be really great if i could just like, slide a transform over the edge of the ledge, so it slides to the position that i’m aiming at… LIKE to slide the gray thing, the ending positions on the picture , slide it where i’m aiming at… IDK how to explain it with words, like i just can’t man.
Like slide it over edge and just by x position
It’s just so complicated, it’s like, i don’t have an idea of how to make it, and i don’t understand you guy’s ideas, becouse of my english skills probbably. And i don’t see why would you waste time on explaining me your ideas extreemly carefully and detaily, i don’t think you’d do it, would you ?
EDIT:
And what did you mean by: “You can’t program a computer by putting pictures in”… ? As i said, i have experience in programming, 5 years actually, but this is something else
