Help with relative offsetting from Wall in Ledge Grab

Hello!

I have a ledge grabbing system in C++ but I’m just having trouble wrapping my head around how to offset from the wall accounting for the direction the wall is facing.

The blue debug sphere is my MountLocation, and I’m trying to move it further off the wall.

	MountLocation = FVector(
		WallTraceImpactPoint.X,
		WallTraceImpactPoint.Y,
		LedgeTraceImpactPoint.Z - (LedgeGrabPointDownOffset)
	);

My variables here are named for what they literally are, saved earlier in the class. I’m basically snapping X and Y to where my tracer impacted the wall. If I add or subtract values from these, I can accomplish what I want but only when the wall is facing a specific direction. I’m not good with math and feel like I am missing something obvious here in how to calculate an offset that is relative from those impact points.

Any help would be appreciated, or let me know if I should provide more info on how I’m doing this. I didn’t want to paste the entire class as it’s quite big and figured this may be enough to get the gist of my problem.

A little more code might have been helpful, but from the video you do appear to be tracing forward first (the blue debug spheres) to find the wall, you want to save the Impact Normal from that hit and you can use this directly (scaled, of course) as your offset.

The Impact Normal is essentially the surface normal of the object hit at the location hit, which is just what you want.

Thanks, this gave me enough to go off on.

What I ended up doing was getting the Normal from that impact point and multiplying that by the distance I wanted (after some experimenting), then add that in my initial calculation.

so

	MountLocation = FVector(
		WallTraceImpactPoint.X + (HitResult.ImpactNormal.X * 45),
		WallTraceImpactPoint.Y  + (HitResult.ImpactNormal.Y * 45),
		LedgeTraceImpactPoint.Z - (LedgeGrabPointDownOffset)
	);

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.