Hi, I’m trying to line trace an object, break the hit result and then calculate the angle the line trace hit the surface at.
I followed a guide I found on the forum to get this:
However the Acos returns 0.038~ when I’d expect it to return 90 from the impact because it’s a 90 degree angle impact. Why is this happening and how can I get it to return the angle correctly?
I’m still learning vector maths, so forgive me for the stupidity.
1 Like
Impact normal is the angle the line trace hit at, no?…
( can’t test it right now )
Also maybe take a look at PredictProjectilePath
Impact normal is the normal of the surface hit, I believe. It returns (1, 0, 0) raw and I’m combining it with the hit location to get the position of the hit on the surface and the normal of the surface (I think)
It’s admittedly more guess work than I would like on my part XD
1 Like
I’ll have a look later, but I thought there was a difference between normal and impact normal.
I think you might have more joy with dot product between normal and impact normal.
Says like this
/**
* Normal of the hit in world space, for the object that was swept. Equal to ImpactNormal for line tests.
* This is computed for capsules and spheres, otherwise it will be the same as ImpactNormal.
* Example: for a sphere trace test, this is a normalized vector pointing in towards the center of the sphere at the point of impact.
*/
UPROPERTY()
FVector_NetQuantizeNormal Normal;
/**
* Normal of the hit in world space, for the object that was hit by the sweep, if any.
* For example if a sphere hits a flat plane, this is a normalized vector pointing out from the plane.
* In the case of impact with a corner or edge of a surface, usually the "most opposing" normal (opposed to the query direction) is chosen.
*/
UPROPERTY()
FVector_NetQuantizeNormal ImpactNormal;
Seems difference was only for Sphere trace and others, if line its same. Same for the Locations vs Impact point they are same if its a line trace. Since there is no thickness in trace that time.
So normal when hit looks inside the plane, so we revert it.
Dot
Normalize(Location of Impact - TraceStart )
and get angle

1 Like