Need Help: Custom Locomotion System - Up Sweep Tracing Issue

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.

im not sure if this is what you mean by ‘doesnt seem right’ but you’d be tracing from the ActorLocation (center) not ground?

Well, I’m trying to do the sweep trace from the ground to character’s height. But… GetActorLocation actually gets the location from the center of the capsule?

Plus, why would the trace, “slightly” pass through the ceiling, to the floor of the obstacle, as on the screen, giving… improper distance?

The free ALS (advanced locomotion system) plugin has a GitHub repo which does this. Can use it as example (uncrouch, probably on animation BP).

Can’t review the code of your system that you didn’t post, but difference formula is always “Abs (A - B)”. (Use FMath::Abs)

I don’t know, I thought it gets its 0 location regardless of what the actor’s components are offset to. Might be wrong though since I’ve seen similar screwy systems in other engines and it seems you have tested this?

Still, you can get the capsule relative location and calculate the extension if you require.

If extremely minimal (to the eye), it’s a float precision problem. If it’s a capsule trace problem, you could still try a line trace, since you’re only interested in the line distance.

  1. I want to rely on my own locomotion system.
  2. ALS uses simple Uncrouch.
  3. Made adjustments to debugging.
  4. I did posted some code, starting as “namespace CndELS_Func”

So why the sphere sweep hit is not hitting the actual ceiling, but over (hitting top of the mesh)? And no, no offset is added.

well id say check the collision profile

and debug a bit more, origin and HitResult. it kinda looks like your line is starting and finishing higher. it could be your line trace is correct but your debug line offset?