How to determine which side of a buildable a line trace hit

I know I can do hitResult.ImpactNormal.Z to determine if I hit the top of a buildable, but doing hitResult.ImpactNormal.Y will give different results based on how the buildable is rotated. Is there any way I can determine "This hit the left side"?
Solution:
I do it like this, if you want to do the switch on enum thing use EFoundationSide
No description
No description
Jump to solution
8 Replies
SirDigby
SirDigbyOP3w ago
I was able to get it working* by doing this:
// Left side
if ((hitResult.ImpactNormal * hitActor->GetActorRightVector()).Y <= -0.05)
// Left side
if ((hitResult.ImpactNormal * hitActor->GetActorRightVector()).Y <= -0.05)
Not sure if this is the correct way, though
Solution
D4rk
D4rk3w ago
I do it like this, if you want to do the switch on enum thing use EFoundationSide
No description
No description
AngryBeaver
AngryBeaver3w ago
You can also use the Transform to convert the normal into local space for the hit object.
Rex
Rex3w ago
I have a slotted buildable hologram that can determine the hit face of a hitbox
D4rk
D4rk3w ago
I got the original info from here https://forums.unrealengine.com/t/how-to-determine-a-cubes-right-left-etc-through-line-trace/369185 The game probably already has a function to do this for foundation snapping but I never found it
Rex
Rex3w ago
Somewhere in here: https://github.com/Th3Fanbus/SmolMachines It's meant to be used with specific buildables implementing an interface to describe the "slots" they have on their faces, but it's possible to adapt for other purposes Ah, found some videos: https://discord.com/channels/555424930502541343/623891487683510323/1225937030245126144 (I think the first video was just a reimplementation of the storage container hologram)
D4rk
D4rk3w ago
There are some helper functions in FGBuildableFactoryBuilding.h
No description
SirDigby
SirDigbyOP3w ago
This works great!
Want results from more Discord servers?
Add your server