How To Create a RenderTarget Material C++

As the title suggests, I am trying to create a material that I can then apply to a mesh. I’ve made a class containing a static mesh, a SceneCaptureComponent2D and a RenderTarget. I can’t seem to understand how to create the material using the RenderTarget. I tried to follow several answers and guides but got nothing. Can anyone tell me how to accomplish this by code? From what I understood, I should use MaterialInstanceDynamic, but I haven’t worked with it before. Any advice would be great atm:D