I’m struggling with my standing up trace, a Sphere/Capsule swept from my character’s location to their default height, used to determine if character can get up to duck or fully.
Thing is - the “distance between” value doesn’t seem right.
Is something wrong with the trace or the object, that makes my stand up function go haywire, ticking between ducking and default desired stances?
namespace CndELS_Func
{
FHitResult Get_Hit_Space_StandUp(ACndCharacter_Master* CharacterTarget, FVector OwnerLocation, float DesiredHeight)
{
FHitResult HR_StandUp_Space;
if (!CharacterTarget)
{
return HR_StandUp_Space; // No valid hit
}
FVector CndOwnerLocation = CndFunc_Owner::GetLocation(CharacterTarget);
FVector TraceStart = CndOwnerLocation;
FVector TraceEnd = TraceStart + FVector(0.0f, 0.0f, DesiredHeight);
if (CharacterTarget->GetWorld()->SweepSingleByObjectType(
HR_StandUp_Space,
TraceStart,
TraceEnd,
FQuat::Identity,
CharacterTarget->CndSys_ODS.Params.CollisionObjectQueryParams,
CharacterTarget->CndSys_ODS.Params.UpTrace.Shape,
CharacterTarget->CndSys_ODS.Params.CollisionQueryParams
))
{
if (CharacterTarget->CO_ELS->ELS_DebugEnabled)
{
// Draw the capsule trace path
FColor TraceColor = HR_StandUp_Space.bBlockingHit ? FColor::Green : FColor::Red;
DrawDebugCapsule(CharacterTarget->GetWorld(),
TraceEnd,
CharacterTarget->CndSys_ODS.Params.UpTrace.Height,
CharacterTarget->CndSys_ODS.Params.UpTrace.Radius,
FQuat::Identity,
TraceColor,
false,
0.0f
);
DrawDebugLine(CharacterTarget->GetWorld(),
TraceStart,
TraceEnd,
TraceColor,
false,
0.0f
);
}
return HR_StandUp_Space;
}
return HR_StandUp_Space;
}
float Get_StandUpSpace(ACndCharacter_Master* CharacterTarget, float DesiredHeight)
{
FVector CndOwnerLocation = CndFunc_Owner::GetLocation(CharacterTarget);
FVector ImpactPoint = CndELS_Func::Get_Hit_Space_StandUp(CharacterTarget, CndOwnerLocation, DesiredHeight).ImpactPoint;
// Get Distance Between Desired Height and Impact Point
float Distance = CndFunc_Global::Get_DistanceBetween(CndOwnerLocation, ImpactPoint);
return Distance;
}
}
void UCndComp_LocomotionSystem::BPF_UEF_CndCharacter_Desired_MVRecovery(ECndCharacter_Movement_Recovery Recovery)
{
float Height_Default = CndCharacter_Data_Params::Get_Height_Map(CndCharacter_Target, H_Default);
switch (Recovery)
{
case MVRecovery_StandUp:
{
float Space_Stand = CndELS_Func::Get_StandUpSpace(CndCharacter_Target, Height_Default);
break;
}
}
}
FYI: Yes, I’m using my in-house debug tool.