How to get mesh verticies/normals that are pointing towards the player

To be more exact, I’m trying to find a way to get the vertices that are pointing towards the player. As of now, I have something that works (code below), I basically get the normals of each
vertice and check if it’s pointing to the player. This works perfectly if the mesh is not rotating, but once the mesh starts rotating it stops working and I basically get the same verts. (See in gif here: https://i.gyazo.com/8681896502960d89f6a68dd6a2b1538f.gif)

I’m pretty sure I’m doing something wrong with the calculation, if anyone knows the answer please let me know. Any help is appreciated!




Screenshot_4

Hi Sntfon100,

That’s just getting the raw meshes verts and normals - you would have to rotate it and scale it to be the same as the mesh in your scene.

Maybe you could do a LineTrace to each of the objects in your scene you’re wanting to test? The Hit Result from that contains a normal of what it hits.

1 Like

Ohhh I didn’t understand it was the raw data, that makes a lot of sense now.
Thanks a lot, I will try your solution :+1:

1 Like

Managed to fix this problem thanks to RecourseDesign for shedding some light to me about GetSectionFromStaticMesh. I did not use the line trace solution because it’s too heavy for my project (I have tons of line traces already).

So here’s what I did:
Since the normals of the vertices are not rotating along with the vertices in real time, I had to find a way to fix that. After a lot of failed vector math, a cool node by the name of “RotateVectorAroundAxis” came along to help. And guess what, it fixed the problem! Check these beautiful normals rotating around (looks like a hairy cube): https://i.gyazo.com/0dab406d948bdfee0a5afc1060409f37.gif

After this, solving my main question was simple, here’s the final code and the result:
https://i.gyazo.com/158ba10bae736a00259c07f9dbc5c438.gif



1 Like