I’m working on some kind of parkouring game, and have a problem. I tried to google it, but not really sure, what should I search.
I want to use diferent animations.
If you run into a wall, but the top edge is too heigh for you, you only step on the wall, and fall back.
If the top edge is reachable, the character will have a full animation of climbing.
I have a simple house, but with diferent heights (Something like this: http://fc07.deviantart.net/fs70/f/2013/040/f/6/medieval_house_by_azuraundead-d5ubgbv.png).
For example on this house you can reach the roof on the arch, but nothing else, if you are staying on the ground.
My concept is the following:
If the character collides with the wall, we check how height is that part of the house, if its bellow a certain height, he can climb up, if not he just step on the wall and fall back.
So my question is, how can I get the height of the mesh on the side of the object, where the collision happened?
Ps: Sorry for my english
I recommend not doing it this way period.
This is going to be computationally heavy. Overgrowth for example uses a sort of edge detect but framerate really suffers because of it. Crysis on the other hand (CryEngine) (and most other major game engines) use a sort of tagging system, where you place a tag of sorts on edges. I don’t know how they did it internally, but a reasonable way to do it is for each edge you want reachable use an AABB and detect when the player enters it (players hand perhaps), then play a climb animation.
Actually, a really good way is to have edges separate game objects. So for example, if it’s a short wall that should be climbable, you only need to detect when the player collides with it (and perhaps the players movement direction, if falling down you play one animation, if moving vertically up play a climb animation. Then, the edge of a roof say would be another separate gameobject, so you again only detect OnCollision with the player, and depending on their movement, play an animation (or not). The bounds of the box could be below the edge say, so you can walk over it without triggering it.
This should be a lot faster and easier. First no raycasts which are expensive. Second, Unity collision systme is already an AABB (fast calculation), it’s less code, it’s adjustable visually so you don’t have to make sure your houses all conform to a certain spec…It’s also adjustable by artists if you are more than a one man team.