[Bug Report]UE crash when getting Material Interface Reference from Hit
My goal is to get the graphical material of the ground where the player stands, and use that to spawn some debris that are similar to it.
I don't even use the Impact Material yet anywhere, it's just an unused input now, but it makes UE crash instantly.
Do you have any idea, how can I fix this, what do I do wrong, or how should I do it instead?
asked Jul 25 '16 at 04:12 PM in Bug Reports
After looking into your project, I believe I understand what is occurring and what can be done to accomplish the task you are looking for. As you stated, the array index < 0, so the crash is expected behavior. Having said this, the Hit Item pin is not going to be useful to you when attempting to get a material, I would ignore this pin completely. For now, you should be able to get the material of the component as you are and simply use element 0 unless you need a specific element in a mesh that has multiple elements for materials. Then, you can check to see if that material is of a particular type (water, dirt, etc.). Based on what selection you use, you can set the particle system to the impact point.
Having said this, there is an easier method, which would be to use a physical material and switch on enum from that physical material that you set. You can set surface types in the project settings>Physics menu. This would allow you to easily set a number of different surface types that your landed effect could spawn particle systems for. Further, you could do it with a simple switch on enum as seen in the image below. There is, however a known bug, UE-33828, that prevents this from being used at present, but once a fix is implemented it is the method I would highly recommend as you will have significantly more control over the end results.
For more information on how to set up and use physical materials, check here:
answered Jul 27 '16 at 05:47 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here