How to get name of UPhysicalMaterial (From FHitResult)
So I am trying to get a name of a physical material, so I can use it for material penetration en deflection for my projectiles. I have a FHitResult that contains a physMat (TWeakObjectPtr). It has the member Get() that returns a UPhysicalMaterial*. Which inherits from UObject.
But I can't call UObject's GetFName() on it. I also can't cast my weakpointer or physmat to UObject to then get the name, since that will give me a compiler error.
None of this works
How do I get the FName of a physical material. In BP it is just GetObjectName.
Any help would be appreciated.
asked Feb 03 '18 at 07:46 PM in C++ Programming
By the looks of it you are trying to use the physics material name to get a row from a data table, yes? If so, I just did a test with a simple line trace and was able to get it to compile, and also return the found row, using the same code as in your image. However, in yours it seems the (presumably) hit result variable you declared may be the problem. Is your hit result a pointer by chance? If so, you should use the -> operator to access the PhysMaterial variable, and then continue with the code you had. I tested that case as well, and had similar success. Hope that helps!
Here is my code. And, I'm using 4.18 by the way
You'd fill in the blanks above with your own code of course.
Follow this question
Once you sign in you will be able to subscribe for any updates here