- Home /
Hanging on a ledge, moving alongside of it.
First and fore-most: I don't have that much experience with game development. I have no idea if certain approaches to a problem are 'right' so I just want it to make it a bit more clear for myself. I am creating a first-person movement controller, which has an ability to hang on ledges.
The way I have it implemented, is that the player GameObject has an empty GameObject as a child, from which it uses Physics.OverlapBox method, to find any GameObjects that surround it. Once that happens, it checks if the highest point of the OverlapBox is higher than the highest point of the GameObjects that it found. If so, it assigns that object to a variable and changes the player state to "OnLedge" (before using a Coroutine to place the player into into the right position) which changes the movement scheme to move alongside it.
Several questions arose:
What if what I am climbing on is not a simple cube? What if it's a more difficult mesh? How would I go around to implement that? Because the implementation that I use now wouldn't exactly work with difficult meshes.
The below picture would be an example. If the whole wall with the orange line would be a mesh, would there be a way to make the player hang onto it and when moving sideways, adjust to the height of it. (If the player would move to the left in the picture, on the slanted edge, I would want his y coordinate to go down as well).
The thing that have popped into my head is using several nodes for that. In the picture example, I would use three. One at the left-most position of the ledge, one at the 'corner' of it, and one at the rightmost position. Then I would find a way for a player to move through those nodes. Is such an implementation reasonable? Because that way, if I am developing a level, I would need to create those nodes for every single ledge that I would want the player to be able to grab on.
Going around corners is a problem as well, but I had an idea in mind that would work using my current implemention. If the actual collider object moves off of the cube GameObject, just rotate the player and put it in the right spot using a Coroutine. But again, more difficult meshes would not work with this method and this whole implementation just feels a little bit off. The node solution for this feels the most right, but again, when designing a level for a game, would it be right to add tons of these nodes to the level, for each ledge I would want the player to be able to grab on?
I'm not a professional game developer either, but i guess that in most games there will be additional invisible objects as markers to indicate where the player can grab, ledge, shimmy etc.
$$anonymous$$g. also vsible in the demo video for this asset: https://www.assetstore.unity3d.com/en/#!/content/67802
Your answer
![](https://koobas.hobune.stream/wayback/20220612104419im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
FPS controller, only for use on object 0 Answers
Movement help 2D Android HELP ME 0 Answers
Gradual Speed Increase with Variable Input 0 Answers
Stuttering Player Movement 2 Answers