[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?

I didn’t put it in the “Bug Report” section. Could a Staff member change it for me please?

Hi CrimsonHawk,

Have the event on landed do an IsValid Check for your hit actor before running the On Impact function. It sounds as though it is pushing a NULL value then attempting to run the On Impact function anyways, which could lead to a crash.

I tried this configuration, and also tried to wire it to the “Hit Component”, but same result both time. If I’d ask only the Point, or the Normal, there would be no problem.

By the way, for error replication: The ThirdPersonCharacter lands on the Floor object from the ThirdPersonExampleMap.

This is more what I mean. If you use the IsValid check on the hit actor pin, it should prevent the NULL value from attempting to populate the impact material if nothing is hit. Try this and see if the crash still occurs.

I tried this configuration on the picture. Similar strange results. It finds the Actor valid, but if I try to read its material it crashes the engine.

This way it writes out Floor as expected. When the wires changed to the material, it crashes. Even like this when the Index parameter is constant False in the Select.

By the way, Event On Landed event is a built in one.

Can you send me a sample project so I can see what may be occurring?

I think I found the source of the problem. The Hit Item gives the Element Index -1. And since it tries to reach an incomprehensible value for Get Material, it crashes. But anyway, I link here a Google Drive link for a small test project. It really doesn’t need more than what I’ve shown on the pictures. Just jump one with the Space and it’s gone.

https://drive.google.com/folderview?id=0B0zfayRWQIKOSEFCa2JudjFTWG8&usp=sharing

Thanks for you fast replies and helpfulness, I will use this solution then! I was thinking about implementing physical materials at one point, but that needs quite lot of other implementations to do, and for now I’m just trying to learn to use other basic elements of the engine. Anyway, returning -1 instead of 0 is still a small glitch, isn’t it? Or is that how it supposed to work?

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][1], 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:

This is expected behavior. The Hit Item returns -1 because there are not additional items within the hit actor to express.