I was trying to change the material of a static mesh, however casting to a StaticMeshActor and using GetStaticMeshComponent was not working. My program has a PointSpawner class which spawns points. I have a MyPoint blueprint actor which has a static mesh and the PointSpawner class spawns instances of that point. However when I try to cast the spawned point to a Static Mesh Actor, Unreal crashes. Why does the cast to StaticMeshActor fail even though the BP Actor has a static mesh component? Why does FindComponentByClass work when the GetStaticMeshComponent fails? Here are some more pictures for information:
What works:
What doesn’t:
MyPoint BP Actor: