Hi there,
I would like to improve the movement code I'm currently using by adding a few new features. Grabbing the ledge of a block of stone or a plattform during a jump or fall (and then climbing upon the grabbed object) is a feature which can be seen very often in various 3D Jump'n'Run and Adventure games (Super Mario 64, Banjo Tooie, Tomb Raider, Uncharted...), so I have been wondering: how do you actually get this done...?
Is there any tutorial or code piece for something like this?
The main problem is detecting an edge in 3D space which is actually suitable for grabbing and climbing. I would have tried to do two traces, approximately from the position of the player entity's eyes to a position a few quants away in positive local x direction. Then do a second trace in the same direction a few quants above. If the lower trace hits something in a short and the upper trace hits something in a larger distance (using an experimental offset value) then we have an edge in front of us.
In side-view, the situation would look like this:
side-view:
(vertical dashes = wall)
|
---|
|<----- upper trace (length: 5)
---|<-- lower trace (length: 2)
|
|
But these are two traces more to do during each frame. Also, if the player entity is moving downwards too fast, it is possible that the critical areas of a surface will never be scanned for edges and therefore the grabbing points will not be detected. Also, this would enable the player entity to grab edges which I do not intend to be used for climbing (e.g. on an enemy entity) - any alternative ideas?
Greets,
Alan