Climbing System for 3rd Person Games
Blitz3D Forums/Blitz3D Programming/Climbing System for 3rd Person Games
| ||
Hello, I'm trying to figure out how to create some kind of climbing system for a 3rd person game. I just want to have the character be able to jump up and grab SOME (not all) ledges. So the beginning is obvious. Make a list of climbable edges (as a list of vertex pairs). Now, the problem is how to calculate whether the player is close enough to the edge to auto-grab it. So, simplified down to the bare minimum, I need to find the distance between a point and a line, but I don't have any code. Does anyone know how to do this? Last edited 2011 |
| ||
I googled it and found 66 million results, so that should get you started. ;-) http://www.google.com/search?client=opera&rls=en&q=find+the+nearest+distance+between+a+point+and+a+line&sourceid=opera&ie=utf-8&oe=utf-8&channel=suggest |
| ||
There is one in the code archive as well, under the 3D Graphics - Math section. |
| ||
Thanks, Warner. I found it: http://www.blitzbasic.com/codearcs/codearcs.php?code=2156 Last edited 2011 |
| ||
Ah, but that one is written in BlitzMax. Would need porting then. There is another one, for Blitz3D, by Danny. :) |
| ||
I'd highly reccomend using a ghost 6 sided box entity for marking ledges, etc. that the player can grab onto - this is what most commercial games use to. |
| ||
Converted to B3D, condensed, and added endpoint support: @Warner: Sorry, did this before I read your post. Oh, well. @Rroff: Could you elaborate on that? Last edited 2011 |
| ||
Hopefully this will show what I mean:![]() The pink colored brush wouldn't be drawn visibly in the game, but is used to mark the edge and the extent of left to right movement and is what is checked against for places where the character can grab onto or perform other moves. |
| ||
If you had searched the blitz forums for related terms you'd have reached this thread where we previously discussed this subject: http://blitzbasic.com/Community/posts.php?topic=82689 EDIT: Sounded a bit more direct than I wanted to. Mah mustake! Last edited 2011 |
| ||
Ah I remember reading that thread heh, naughty alien suggested the box trigger method there too. |
| ||
I didn't mean to cause anyone any trouble. Honestly, I didn't know what to search for - it's a very vague concept (actually a very specific concept). So I think I understand the box trigger method, but I think it might end up being a little inaccurate. Just to be sure, is there a way to adjust the player when a collision is detected so that they are "hang-aligned" to the ledge instead of wherever they were when the collision occured? |
| ||
With these systems its better to be a little inaccurate than too accurate as otherwise it can be fiddly and frustrating for the player to use - you might pull it off every time in testing because you implemented it and know how it works, a random player might not. The middle of the box coincides with the edge of the ledge so you can work out the positioning from that. |
| ||
OK, thank you for your help! Case closed! |
| ||
I have coded a parkour demo and the character was able to jump and grab ledges. What i have done is i have defined 4 trigger areas depending on where the hands might be when the player is near the ledge. The player has a collider sphere on him, and each frame the program used linepick ahead of the player. If the normal picked was in the range of the areas where player can grab, and the normal was in the range of what ledge can be grabed or not (for example NY# = +1.0), then the character was oriented, positionned, animated on this ledge depending on the area that was triggered. Watch this old demo : http://www.youtube.com/watch?v=_dk0hrtgquo One bug that you can see on this demo, is that the character sometimes go through the ledges. This is because you have to calibrate the lenght of the linepick depending on the velocity of the character, else the linepick is not able to detect the ledge before the player go through it... |
| ||
@Rroff, can you please show us a working example of an object grabbing onto a ledge, shimmying across the ledge, and slowly using both arms, crossing the ledge while it is grabbed? I'm sure everyone will appreciate it! :) Thanks! :) |