Is It Possible To Use a Trigger Volume To Automatically Apply Material To Objects In A Scene That Makes Contact?

Is It Possible To Use a Trigger Volume To Automatically Apply Material To Objects In A Scene That Makes Contact?

Trying to attach a trigger volume to a moving actor so any object in the scene it makes contact with has a material applied to it. Trying to do it so not every object needs to be listed in a blueprint.

What sort of objects are coming into contact? Are they all meshes, or blueprints ( of different kinds )? Or?..

We really need more info here to be sure - but I’m going to make a few assumptions and explain how I would do it based on them

Assumptions:
You’re using a box collision in your moving actor
The objects you’re trying to change the material for are static meshes inside of actors.

If these are the case, then what I would do is use an interface - give it a function called “ChangeObjectMaterial” or something of the sort. In your actors that need their meshes material changed, implement the interface, and do the logic for changing the material on the ChangeObjectMaterial function/event

In the moving object with the box collision, do an onComponentBeginOverlap, and out of the other actor use a “does implement interface node” do a branch to check if the colliding actor uses the interface, and if so, out of the other actor, call “ChangeObjectMaterial”.

Thank you both.

Here’s the scenario, main actor is a car reversing and stationary obstacles are assigned green, yellow and red based on distance from the approaching car. Originally tried to constantly measure the distance vector between the main actor (the car reversing) and stationary objects to assign them the color using 2 conditional nodes to change color from green to yellow and then to red. Each object was a static mesh actor and had to be assigned within the BP. As the the number of objects increased, things got hairy. Hoping I could use 2 concentric trigger volumes shaped in a cylinder moving with the car doing all the work to assign the color to any object in the scene. Objects can be actors or components, whatever would be the most simple to manage.

Yea in this case I would use an interface that gets implemented in the obstacles and gets called from the car. The car just triggers the function/event, the interface function inside of the obstacles does the logic. Furthermore, I would probably create a parent actor for the obstacles, so that I’d only have to implement the interface once on the parent. Unfortunately, I’m not at my home computer to show you atm, but if you still need help with this later ill post pictures.

Edit: Also, I might consider using a multisphere trace on the car, to detect the surrounding obstacles, and the compare their distances, instead of using triggers