The nice part of programming is there really isn’t a wrong way to do it. There are only more efficient ways of handling things. I personally would go with the idea of a volume-box that recognizes an actor in the area so long as a particular button is held.
I believe this to be much more modular due to the fact that you could scale it in any way you wanted or shape it to specific ledges. The down-side to it is you’ll want to place this on every conceivable ledge so for procedural generated terrains and maps you’re going to run into an issue.
Whether you use a mesh or actor or honestly anything so long as it fits your needs then it doesn’t really matter in the end.
Here is a quick RayTrace example to get the name of an actor. Simply use this function and name the actor whatever you want in the editor. This way if you can just make one, copy and paste it over and over and shape it however you’d like. This should help to get you started.
((P.S don’t mind the messiness of the code! Organize it how you’d like. ))
FString * AProjectX2Character::GetName()
{
FVector CameraLoc;
FRotator CameraRot;
GetActorEyesViewPoint(CameraLoc, CameraRot);
FVector StartTrace = CameraLoc;
FVector EndTrace = CameraLoc + (CameraRot.Vector() * 5000);
static FString testString;
FCollisionQueryParams TraceParams
(
FName(TEXT("GetName")),
false,
this
);
FHitResult HitResult;
if (GetWorld()->LineTraceSingle(HitResult, StartTrace, EndTrace, ECC_Visibility, TraceParams))
{
AActor * ActorTest;
if (HitResult.GetActor())
{
ActorTest= HitResult.GetActor();
if (HitResult.GetActor()->GetName() == "TestingName")
{
testString = HitResult.GetActor()->GetName();
}
else
{
testString = FString("Nothing");
}
}
else
{
testString = FString("Not an Actor");
}
GEngine->AddOnScreenDebugMessage(-1, 5.0, FColor::Red, FString::FString(testString));
DrawDebugLine
(
GetWorld(),
StartTrace, // Start Trace
HitResult.Location, // Hit Result Location
FColor(255, 0, 0), // Red
false, // Persistent Lines
5.0, // Time
0, // Depth Priority
5.0 // Thickness
);
}
return & testString; // return the address
}