- Home /
Gothic-like climbing and edge detection
I'm using edited FPSWalker Enhanced script for my 3d movement - it uses character controller and I may paste it here if it is needed for anything. As subjects says I'm trying to make a climbing script which in use would look like the one seen in Gothic game series. I hope those few points and the pictures will clearly illustrate what am I talking about.
Player presses the climb key and capsule checks if there is an obstacle in front of it - first I thought about raycasting, but I think making a box collider in front of Player will do better in this case, because as we can see in the red box, climbable obstacles may be short (a), tall (b) or short but above the ground (b) - the box collider will detect all of them.
Second thing - I have no idea how to do this - is to check either if the obstacle has a surface player may stand on, or an edge he can 'catch'.
Next thing to do is to check the distance on z axis between the edge/surface and player's center of the mass (or any other fixed point). If it is smaller than float _reach, then the climbing can be performed.
Climbing itself is simply a)temp movement and gravity blockage b)moving player up for distance + 1 (to be sure) and moving player forward for let's say 1. Then unblock movement and gravity.
I'm not familiar with all C# and/or Unity commands, therefore if you have any observations and ideas please do tell. Especially on the subject of edge detection, as I can't think of any solution. Thank you all in advance
PS - There might be some suggestions about marking climbable objects somehow - tagging, or putting them on one layer. I'd rather not, because as you can see on the poorly drawn picture point 4, I want to be able to detect terrain edges as well.
Second question here - for 'jumping over/sliding under while running' script I want to be able to check if the obstacle is either a) from red box or c) - a) is the same as in question above, but for c) I'm going to need to check if there is enough space under an object for player to fit, so that the slide can be done automatically when player is running (either bool Sprint is true or Shift key held down)
Your answer
Follow this Question
Related Questions
C# How to Detect Edges of a Collider 0 Answers
Continuous touch detection problem. 0 Answers
Edge crossing detection 1 Answer
Collision error 1 Answer