- Home /
Edge detection using C#
Heya!
So I'm making a parkour system for my game. My own way to do it (Atleast I figured it out myself) is by adding an invisible trigger object and attaching it to the in front of the character. But my problem is that I don't know how to detect an edge that can be jumped (or vault) over. I'll add an image (made in Paint :P) that will explain the whole thing.
The black "box" on the left is object that can be jumped over, the red rectangle is the triggerobject and the "human" on the right is the player character. btw. The edge may be smooth too!
I know that this can be done (mayby) more easily by adding a trigger object to every corner that can be jumped over. I'll use this way if my "own" way is too complicated.
And yes, I'll use C#.
Thanks in advance!
Answer by Armand · Jul 09, 2014 at 06:48 AM
Instead of a single box you could test two (or more) small trigger points and compare them. For example, one trigger could be on chest level and the other one on foot level. Check both trigger positions - if they are both colliding with something, the player is facing a wall, but if only the lower one is colliding, the player is facing an obstacle that could be vaulted over. Adjust the positions of the triggers or add more of them as needed!
Hey thanks! Why I didn't thought about that?! I'll try (or use) this.