Hey so, im developing a sort of procedural Vaulting,Climbing system ( think of Mirrors Edge ) So far so good but i hit a issue with the tracing, here is a picture of the issue
My “Straight” traces to figure the mesh height work fine when i add the player rotation to them, the “Down” traces to figure if its long enough to be vaulteable Do not use the player rotation even tho
i add it on the code
void AProojectCharacter::TestTrace()
{
FVector StartTrace;
StartTrace = GetActorLocation();
FVector EndTrace = StartTrace + Direction * 100; // and trace end is the camera location + an offset in the direction you are looking, the 200 is the distance at wich it checks
FVector BestHitLocation;
FVector WidthEndTrace;
bool bVaultHeight = false;
// START STRAIGHT TRACES ///////////
// Perform trace to retrieve hit info
FCollisionQueryParams TraceParams(FName(TEXT("WeaponTrace")), true, this);
TraceParams.bTraceAsyncScene = true;
TraceParams.bReturnPhysicalMaterial = true;
FHitResult Hit(ForceInit);
if (GetWorld()->LineTraceSingle(Hit, StartTrace, EndTrace, ECC_WorldStatic, TraceParams))
{
// If we hit an object, start the scanning process
for (int i = 1; i <= MaxVaultHeight; i++) // increase the Z a bit each trace so it goes up
{
StartTrace.Z = StartTrace.Z + VaultZIncrease;
EndTrace.Z = EndTrace.Z + VaultZIncrease;
if (GetWorld()->LineTraceSingle(Hit, StartTrace, EndTrace, ECC_WorldStatic, TraceParams))
{
// if we still hit the object after the max Height then its too high to vault
DrawDebugLine(
GetWorld(),
StartTrace,
Hit.Location,
FColor(255, 0, 0),
true,
20,
0,
1
);
}
else
{
// If we dont hit the object ( before the max increase ) then its not higher than us
bVaultHeight = true; // height is vaulteable
BestHitLocation = Hit.Location; // Grab the object height
break;
}
}
/// END STRAIGHT TRACES ////////
//START "DOWN" TRACES /////////
if (bVaultHeight) // "Down" Trace to figure if the object is long enough to vault over it
{
StartTrace = BestHitLocation;
WidthEndTrace = StartTrace + GetActorLocation().Vector(); // Add the player rotation, here
StartTrace.Z = StartTrace.Z - UnitsToTraceDown; // 65
for (int i = 1; i <= MaxVaultWidth; i++)
{
StartTrace.X = StartTrace.X + VaultForwardIncrease;
WidthEndTrace.X = WidthEndTrace.X + VaultForwardIncrease;
if (!GetWorld()->LineTraceSingle(Hit, StartTrace, WidthEndTrace, ECC_WorldStatic, TraceParams))
{
SetActorLocation(WidthEndTrace);
}
DrawDebugLine(
GetWorld(),
StartTrace,
WidthEndTrace,
FColor(255, 0, 0),
true,
20,
0,
1
);
}
}
}
// End "down" traces /////////
}