I’m trying to make a system where if a character touches a box trigger when entering a room or walking in a specific area, the base color which is a vector 3 parameter changes to a different color and returns back to the normal color when leaving the trigger. Also would it be possible for the color to gradually change instead of instantly changing color.
I’ve been trying to find information about how to do this and ended up breaking my project.
You need to be able to touch the color in your material:
in your material make the color an exposed parameter. make a material instance and access one of it’s properties in a blueprint
If you make a material parameter collection (MPC) and point your material to the collection, you can change the MPC value directly and it will flow into the material automagically
you can do the same thing as a custom primitive data, it’s like the MPC but the values are stored on the mesh directly
Once you have one of these set up, you can do whatever processes/maths on your material parameters and it should just-flow back in to the material.
the function is called “set vector parameter value”.
mid is more intended for “one use” materials.
mpc is more intended for global changes you want to automagically distribute to all material instances that use this mpc.
custom primitive data is more intended for “static” or procedurally generated gameplay element changes. the function for that is called “set custom primitive data vector”.
in either case you can get away with a single float. you could use a color curve or a lerp inside the shader/material.
to fade it you gotta compute the fade over time in the blueprint. just a lerp with some delta time math you gotta compute on tick. basicly…
on begin overlap. set fade active. set fade direction up. enable tick. on tick do the fade math and “svpv”. and disable tick when done. on end overlap it’s the same just the fade direction is down.
there are some nuances to make this clean code. i’ve done that with bpi. so you interact with another actor that does the tick management on it’s own.
trigger logic. is currently begin overlap only. you could change the intensity parameter to your fade direction and/or make it function on end overlap aswell.