Download

Duplicate Class, Shared Variables

Hi Community! I’m a pretty experienced programmer, but I’m having some trouble understanding how some visual code works in Blueprints. Right now, I have some pawn object classes that swaps colors based on variables in my custom Game Mode. It works while I have one type of object that the variable is referring to. However, when I duplicate this object class, it negates itself and doesn’t change color at all, so:

I can have 1 cube(white) that turns blue. When I have 2 cubes(white), the cubes, I assume, turns blue, but since there are 2 instances, the color is left white. As you might have concluded, changing the colors of the objects only works if I have an odd number of instances in the scene as it enables, then negates, then enables.

Does anyone know how I can bypass this? Any help would be appreciated. Thanks! :slight_smile:

Assuming I followed that, there is a simple control structure:

What BP is creating these color-changing object instances?
If Gamemode, then at spawn expose color change property.

Have ‘Gamemode’ set the alternate color changes needed.
Rather than let object instances decide, when they can’t etc.

Sorry, I’m bad at explaining this. But yeah, each object has the color switching property. So you’resaying instead, have the color switching property inside the game mode. That way, there won’t be any duplicate logic going on, negating the switches, right?

Yes have Gamemode house-the-logic and drive the whole process etc.
The actual ‘Color-Property setting’ itself can remain inside each object.
Tick ‘Expose-on-Spawn’ in variable properties to get a Spawn variable.