When providing a Material Slot Name in the “Get Material Index” tha mesh does not have and plugging the index into “Get Material”, the Engine Crashes
Hey Raildex_-
Where are you setting up this blueprint? What is in the Material Slots array? Can you provide all of the setup steps that lead to the crash? Also, can you provide the callstack and log files from the crash for additional information?
- Take any Mesh (Static Mesh or Skeletal Mesh) and see what Material Slot Names it uses
- Put it into a Blueprint.
- use the Get Material Index() Node at BeginPlay, provide a name of a valid Material Slot.
- Plug the resulting Index into “Get Material()” Node
- Output the resulting Material into Print String
- Execture. Everything works as intended
- Change the Material Name to something not correct
- Execture again. You’ll see the Game crashes when you try to retrieve the Material. The Material Index returned is -1. The Crash is caused by getMaterial()
Crash Report:
(Array Index out of bounds, because of get Material Index is -1)
Log:
Hey Raildex_-
The crash you’re seeing is caused by the return value of your Get Material Index node. When the slot name is invalid, the return value is -1. Using this value in the Get Material node, which is searching an array, causes the crash b/c -1 is always outside of the array bounds. I have reproduced the issue and have created a report for it here Unreal Engine Issues and Bug Tracker (UE-41774) . You can track the report’s status as the issue is reviewed by our development staff. Please be aware that this issue may not be prioritized or fixed soon.
Cheers