When character possesses object the object changes color

hey guys,

So basically I have it set up to where my default character can possess an object and move around as that object but I want the possessed object to change colour once it is possessed. I have linked a picture to my code below.

You will have first to create a Material with a parameter, even as simple as the following one:

Then, in the Blueprint of your possessable object (which in your case, as I can see from your code, it is a Pawn, and you use the player controller to posses that pawn), you need to create a Dynamic Material Instance, and assigned it to your mesh (I assume that Static Mesh is the mesh characterizing your pawn), better if you do this in the construction script, and hold a reference to the material (if you use the shortcut to promote the pin to a variable, remember that it is not a local variable). Also, don’t forget to select the material you have just created.

Finally, at the end of your code, you can just get your dynamic material (from the pawn) and set a parameter, in this case it is a vector, and the name needs to be the same you gave it in the material (in this example “BaseColor”). As you can see, you have a pin in which you can select a color or assign one with your custom logic.

Hope this helps. If you have other questions, let me know.

Hey thank you so much for the fast response my character is a 2D sprite will this still work for my character?

Assuming your sprite relies on a material, then yes. In this case, you can either have a color parameter which you can change, or if you prefer, you can have a whole texture as a parameter, and change that dynamically.

Screenshot - 4284b84f20b70b89a52edb51a8e50eb9 - Gyazo My character is a flipbook sprite

I just want to say thank you again though for the fast response and I will look into ur suggestion I really mean it man without people like yourself helping others it would be very hard to progress forward I only hope that in the future I can help others how you have helped me.

In this case, you can either use the Set Sprite Color function on your “Sprite” component (which is a flipbook component)… Or if this is not your case, you can just use the Set Flipbook function, and you can select another flipbook (which can contain anything you want, such as a variation of the sprite with a different color).

299468-sprite.png