How can I perform a debug trace in code?

I’ve been trying to find the source of my CharacterMovementComponent determining if a surface is walkable. It appears to be setting bWalkableFloor and bBlockingHit to false when my character steps onto the wall (a 90 degree surface) My character can walk on any other degree surface below or above 90 without any problems. When he steps onto a 90 he slides around like he’s on ice. I can control him slightly because Air Control is enabled. I believe something is happening during the sweeps and is setFromSweep turning those values to false. So I need to visually see what is happening with those sweeps. I figured I could plug in the start and finish vectors (with an added amount to the end of the “end” vector) and see if something strange is going on.

Thanks

Something like this seems to have worked also.

DrawDebugLine(GetWorld(), CapsuleLocation, CapsuleLocation + hkvCompToWorld(FVector(0.f, 0.f, -TraceDist)), FColor(255, 0, 0), false, -1, 0, 12.333);

Hi, if you know “trace tag” from these sweeps you can plug one of them into:

UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject);
World->DebugDrawTraceTag = TraceTagYouWantToVisualize;

To visualize traces.

Wow this was really helpful. They’ve already added a bunch of these throughout the CharacterMovementComponent so I can just jump off of them.

I tried using “QueryParams.TraceTag = ComputeFloorDistName;” which is listed in the ComputeFloorDist method. I believe this is where my problem is with the bBlockingHit turning false.

When I turned used “World->DebugDrawTraceTag = ComputeFloorDistName;” it put up a lot of different traces. Not just a line from the capsules center but also a floating capsule colored in purple. The problem is that it runs incredibly slow with this turned on. Even though the information appears to be showing me an underlying problem that I’ve been searching for. The purple capsule appears to indicate that something isn’t rotating the way my actual character capsule is. I have no idea what this purple capsule is but it clearly stays vertical and doesn’t follow the character capsule as I walk up the slopes. So, at 90 degrees this capsule is parallel to the floor I’m trying to walk onto. I believe this is the problem I’ve been encountering.

Any ideas on how to get it to run better? It’s pretty choppy. Also does anyone have an idea what this ComputeFloorDistName Trace tag is drawing on the screen, specifically this purple capsule? I need to find where this is in the code and get it to stay oriented the way my character capsule is.

Thanks a bunch!

The image above the capsules are white but they are normally pruple-ish. Not sure why they are white in that shot.

In the CharacterMovementComponent in ComputeFloorDist the Trace tag that I’m using is set just above the SweepSingle that I believe is causing my bBlockingHit to turn false. Just below the trace tag there is a collision object created which is used in this SweepSingle.

FCollisionShape CapsuleShape = FCollisionShape::MakeCapsule(SweepRadius, PawnHalfHeight - ShrinkHeight);

Is there a way I could rotate this collision object? I think this might be the culprit. It never rotates with the character so by the time it get’s to the 90 degree wall I believe it’s perfectly parallel and causes something not to measure up.

Yes that is exactly the line of code I’m trying to fix. In mine it looks like this:

bBlockingHit = GetWorld()->SweepSingle(Hit, CapsuleLocation, CapsuleLocation + hkvCompToWorld(FVector(0.f, 0.f, -TraceDist)), FQuat::Identity, CollisionChannel, CapsuleShape, QueryParams, ResponseParam);

The difference being that the End of the sweep is derived from my method which rotates a vector to orient to the character capsule. My character runs around on the inside of a sphere. hardly ever Z is up logic. So instead I always face the capsule towards the center of the world and this becomes his up vector. So I transform most Z is up logic to orient to my characters up vector.

The capsule being used in the Sweep single called “CapsuleShape” doesn’t orient itself to how my Character capsule is. Instead it always remains Z is up.

I think you should record a movie, it is really hard to understand what is your problem:)

bBlockingHit = GetWorld()->SweepSingle(Hit, CapsuleLocation, CapsuleLocation + FVector(0.f,0.f,-TraceDist), FQuat::Identity, CollisionChannel, CapsuleShape, QueryParams, ResponseParam);

FQuat::Identity

Actually I just tested this concept by converting that capsule in the Sweep Single to a sphere. Now my character doesn’t slip around. I have full control everywhere (Finally!!!) I guess my last question would be if I could rotate the actual CapsuleShape to orient with my character’s, because using a sphere feels technically less accurate.