Need a way to merge mesh variables into one or more mesh variable group to control

Hello there. I’m trying to create some functions for a car blueprint that I’ve made, where simply interacting with it would either turn the lights on and off. I’ve had to make the meshes myself since they didn’t come as separate meshes from the car itself, but my implementation so far of giving each light an on and off state + spotlights for each light (along with a blue/pink overhead spotlight for testing purposes) seems to be rather cumbersome. Are there any suggestions as to how i can simplify this?

Note that I hate 2 headlight meshes, 2 turn signal meshes, and 4 rear light meshes that I need to control, one by one. Surely there’s a way to put each one of these meshes into their own groups.

1 Like

If you give both headlights the same material instance, you can control them at the same time, but all the other lights need to be independent, so not much of a win there.

You’re creating the material instances every time something changes

You only need to do this once. On begin play or in the construction script, and assign to variables, which you later change the parameters on. Get the reference from here

image

image

hl2

Going off by your suggestion, I’m guessing the resulting scripting is supposed to look like this?

I followed your advice to simply create the dynamic material instance once on Event BeginPlay, and returned it into Headlights_Mat, and this is the result.

It works just like it’s supposed to, but now it’s way simpler to use. Is there no chance that I can simplify it even further? It’ll likely still be quite long when I have to involve the other lights, such as the turn signals and rear lights.

You’e still trying too hard :slight_smile:

I put this in construction

then the toggle goes

You can set the intensity at the same time as the color, if you want

col

Well technically, if by intensity you mean the glow/emissive effect for the material, I’ve pretty much separated the color and glow into two different parameters. But at most, I only needed to change the Glow parameter since unless for certain colors, the base color tends to be the same.

The suggestion to put the material instance creation in the construction script was definitely helpful though. Makes things way more readable, in my opinion. Although the ToggleHeadlights scripting already looks pretty similar to mine, but I feel like both should share the same material instance node for the sake of readability.

Thanks for the help.

1 Like

Yes, one material reference is clearer.

You can easily change this, so it just references an emissive strength parameter. In which case the node would be ‘set scalar parameter’.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.