How to change material on a actor dynamically after getting hit with player projectile

Hello all. I am currently working on a C++ project to trying to change a procedurally generated cube’s color from red to green, using pre made materials. Was there anyone that can give me pointers on how to do this?