Hi guys,
I’m currently making a a simple ledge grab system, however i’ve run into a problem.
The character can grab ledges at any angle, for example along a curve of a cylinder. I have the character grabbing the ledge at the correct position but i’m trying to get basic climb and drop behaviour, so if the player pushes in the direction (or approximate direction, maybe using a tolerance) then the character will climb up, if they push away from the ledge they will drop and if they push to the extreme left or right of the ledge direction nothing happens. Please see the picture attached.
I currently have an FVector of the direction the ledge is facing and i What i need to do is get the direction of the stick input and compare that with the direction of the ledge grab trigger box (this box is a trigger volume that checks for the character and snaps the character to the ledge with the correct orientation and location) Note that the trigger always faces in the opposite direction for the ledge. See the picture below.
I currently have this, but i find that at some angles the character will climb, or drop when they shouldn’t, for example holding the stick directly away from the ledge.
// If the direction is within a tolerance of the ledge grab direction climb up
if (FMath::IsNearlyEqual((float)xVal, (float)CurrentLedgegrabDirection.X, (float)CharacterStatsData->LedgeClimbDirectionToleranceX) || FMath::IsNearlyEqual((float)yVal, (float)CurrentLedgegrabDirection.Y, (float)CharacterStatsData->LedgeClimbDirectionToleranceY))
{
ClimbFromLedgeGrab();
}
else
{
DropFromLedgeGrab(CharacterStatsData->LedgeDropVector);
}
The code above takes the value of the input from the stick and then checks if it is within a tolerance of the X or Y axis of the ledge direction… Z is not needed. I may well be doing this the total wrong way and i’ve been scratching my head about this for ages, I’m fairly new to vector math and have read about the dot product to get angles between vectors, but have tried with odd results.
Any help would be appreciated.

