Download

[Climbing System] Matching body to Edge

I have been creating a less advanced climbing system that everyone else seems to be creating, instead of using tracers to get the edge of a block i am using trigger boxes to start the event of climbing, meaning my way is not automatic like the more advanced ones that are being created.

My issue is that i am having trouble matching the players location to the edge of the wall, note that i do want this to work on all angles which is why i have not done the obvious of matching x y to to the blueprint, also note that the blueprint is actually not attached to the wall and theoretically would work without the wall actually being there.

Issue Picture:
problem.PNG
As you can see, the player is not ‘on’ the wall.
Blueprint:
If you need to see any other part for some reason let me know, the picture below should contain all the important parts.
problembp.PNG
I even tried adding a forward vector to try and push the player forward however this isn’t the best way as the player could jump from any distance and hit the trigger box.
problembpc.PNG

Sadly i can not think of a way around this, lack of knowledge is to blame :slight_smile:
if any help can be given i would be very thankful.

hi.
I don’t really get what you’re doing in your script, like what are last player pos and origin ?

Ah sorry forgot to mention, Last Pos and Last Ang are set when the player hits the trigger (only happens once) as i found it more difficult to work with a live vector, hense last pos and last ang, also the Origin is what the player ‘moves’ to its shown in the last image its a scene component so no visual representation.
Basically the script moves the player to the scene component currently its only needed for the Z axis, as i dont want to ‘lock’ the player to that position i want the player to eventually move along the bar.

Well, I don’t know if I got everything right, so sorry in advance if I’m wasting your time but it seems to me that snapping your player only on Z may be your problem here. Because since your trigger has width, and your character will be playing animations, you never know what the character’s position will be, relative to your edge, when he’ll touch the trigger.
If I’m right, you should just go with a two time process.
At first, when the character touches the trigger, you just blend its position to the closest correct 'hanging" position. On all axes. Just like you’re doing with rotation.
Then, when it’s done, you give your player freedom on lateral axis, only keeping Z locked.

Sounds like help ?

I see where your coming from and that does actually help me out, the thing is though the bar can be scaled so that it is longer, which means the player can ‘latch’ onto it from any position along that bar meaning i dont want to to ‘snap’ to the centre of the bar as thats unrealistic, and where you mention

im not sure how i would blend from where the character is to where it matches the bar.

Those are two different problems.
First, when the player hits the trigger, you don’t know where he is compared to the bar? You just have a very fuzzy information telling you that a part of its body touched the trigger somewhere. So from here, you’ll need to run tests to get a more precise info.
Then you need to determine what is the closest correct position for him to hang, from where he is right now.
And finally, you need to blend his current position to this new position you just determined.

And, from the hanging animation you made (looks very nice BTW), you neet to know what is the offset of the character’s origin from the edge. So when you have determined where is the point on the edge you want to player to hang from, you add this offset to place it right.

What I would advice:
When the player hits the trigger, try to ignore Z first, and determine the X,Y location of the closest point of the edge to the player. For this, trace from the player, with a vector that’s perpendicular to the edge direction. where the trace hits is your point on the edge. You need to do that only with X,Y, so probably you’ll have to create a vertical 2Dplane for your edge.
Adjust Z to your edge’s height.
Apply the offset from your animation.
Blend the player’s position to this new position.

I’m a bit sleepy, so it may not be perfectly clear. Do you still get the basic idea ?

Ah yes, that works in my head and is doable, even in your sleepy state :slight_smile: thanks for the help ill see what i can do and post the results, just needed someone to push me in the right direction.
thanks :slight_smile:

Cool, because reading myself after I wrote the answer, I wasn’t even sure to understand myslef =)
In the meantime, I already thought of simpler, more elegant ways to achieve the XY test, but the logic stays basically the same. Play around with the idea and you’ll find seomething great since you got the logic now.
Have fun making this nice character move gracefully =)