Download

Turn off shadows by default when creating new mesh component

How do I have Dynamic Shadows or Cast Shadows be turned off by default when I create a new mesh component in an object blueprint?

I have a lot of objects to create, and 90% of their meshes shouldn’t have shadows. At that point, it would be more convenient to just have them be created with the Dynamic Shadows box unchecked and then check it when I want shadows. Is there anything that I can change in Unreal to make this happen? I’m open to C++, editor, or other methods

I’ve tried making another component in C++ that would go through all the meshes in my object and turn off their shadows, but it only runs for an instance of the object, and the changes aren’t reflected in the BP editor. Also, because it just runs through all the meshes, if I did want shadows in one, it would still set Cast Shadows to false.

Quickest and most brute force way I can think of is to subclass UStaticMeshComponent and in the constructor disable all the shadow variables that you don’t care about. They’re defined mostly in the UPrimitiveComponent class.

You use that new subclass in your Blueprint actors instead of the regular static mesh component and you can still enable shadows for the ones you care about.

1 Like