Two players Overlapping a TriggerVolume

I have two different players in my level, a Trigger Volume and an object that changes material deppending on which player is overlapping the Volume, If player 1 is inside the object, it turns blue and if player 2 is inside the object, it turns red. If there are no players overlapping the volume, the object becomes white, My question is, how can i turn the material white (neutral) if both players are inside the volume?

To expand on Scott’s article link…

Assuming the trigger volume is a component within the object you’re talking about…

  1. In the tick function for the object,
    call the “GetOverlappingActors” that
    Scott references. Be sure to use the filter so you’re only returning actors of the proper class.
  2. Use a ForEachLoop to go through
    those actors and process them as
    necessary to identify how you want
    to color your material. For
    example, two members of two
    different teams yields setting the
    color to white.

I would recommend setting up a boolean variable that turns true when an actor of the type in question begins overlap, and then setting that variable to false on End overlap if the resulting array from another “GetOverlappingActors” node results in a length of 0 (no overlapping actors).

This way, in your tick function, you only process actors if the boolean is true. So that way, you’re not wasting cycles querying for actors when no one is overlapping.

It would look similiar to this Screen Capture I took a while back for another post, just replace that Array mess with the “GetOverlappingActors” bit.

Here is what I tried, But nothing happens, I tried printing a string after setting the booleans to see if they were being set correclty but again nothing, also it is not failling to cast the GameplayPC

edit*
Setting the array as a variable gives me the same results

If you asked about trigger actions, not actor overlap, I suggest something like this:

  1. you should add tag to players as tag #1, it will be Player1, Player2 (and can be easy more)
  2. on you trigger box (or other trigger) create OnActorBeginOverlap(TriggerBox). It will create event on level bp
  3. add PlayerCount variable as Integer to level bp

In pic 1 no reset player count so here is update

][2]

Instead of Print String “Make it Red” or “Make it Blue” nad White, you should use material instance for physical coloring.

This should be something like this:

133329-color_it.jpg

You have to split Value in Set Vector Parameter and for Red Value R is 1, rest 0, for blue B is 1 - rest 0, and for white all zero as I remember.

This is not production solution, just some direction but should be enough for start.

try printing the length of the overlapping actors array, it will help you debug it. make sure the collision of the volume is set to GenerateOverlapEvents and set to overlap all. is your GameplayPC a type of pawn or character?