Identify the direction of a face

Hi i have a (maybe silly) question.

If i do a line trace and i hit an object, is there a way to find out in which direction the hit polygon is facing and align an object to it? I have build some kind of interior editor and specially with wall objects it would be nice if i could align them directly to the wall.

Oh our project is BP only atm.

The resulting hit record contains the normal for the impact point. I think you could use that to help solve your problem.

thanks i have managed it. There was a rotationFromXVector Node that that solfved it :slight_smile:

could you elaborate please? maybe a screenshot? I’m not sure how to use that node

Rotation from XVector just gives you the forward vector of the actor in degrees.

Kind of old but I stumbled on it while making my Portal-Gun. I fire a projectile which creates a portal Sprite “onHit” and I want that portal to have a rotation that is exactly like the walls polygon the projectile hit. (Long story short: just like in the game “Portal”)

The “rotationFromXVector” Node really solves that. Here is an example of my BP which delivers a Transform with location of the projectile (Can easily be replayed with “hit location”) and the rotation of the “polygon” (mesh) that was hit.

Projectile that spawns a portal on hit (only at worldStatic and worldDynamic):

In my example the Sprite of the spawned portal behaves like a decal (has the right rotation compared to the “wall” it’s laying on)

This is just a start to solve the problem in the question but I thought I share a pic so maybe others get an idea of what is going on.

1 Like