ForEachLoop doesn't set material

Hi there,

I’m trying to build a level creator system with a container that stores each object’s data in a data container. The data stored in the data container (for now) is an reference to my actor and a location vector. This data is set when spawning in an object.

70144-checklocations3.png

When I place an object, each object has a data manager that spawns and the data for each of the object gets set. When the ‘marker’ version of the actor is at the same location as the placed object it sets the material to not valid (as shown below). This is so you wouldn’t be able to place multiple actors at the same location as the already spawned actor. The following screenshots are an example of 2 placed actors but only the most recently placed actor gets set to invalid.

The problem I’m having is, when the ForEachLoop runs to detect the locations of my objects, which is stored in the data container, it only sets the material to be invalid for the most recently spawned actor, when it should be doing so for all of the actors if the locations overlap.

NOTE: The strings that are printing are the locations of the two placed actors (in white). When I tested this the ‘marker’ actor location can be the same as an actor but it doesn’t set the material to red.

It’d be far simpler to use collision boxes instead. If the overlap is triggered, change material.

As for why only one is getting changed, I can’t really determine that without knowing more… Most likely an issue where you’re setting the data. Have a screen of that?

I did try ‘Is overlapping actors’ but that didn’t work as I want. I mainly created it this way to allow users to save and load the levels they have created.

So firstly it checks if you’re in placement mode, then if you are, it places an actor at the location of the ‘marker’ actor (the marker actor is the same type of actor as the others just with different materials.

Next, it gets the actor location and saves it into a struct (for saving and loading). Then it spawns the data container which sets some variables (shown in OP); the spawned actor to be the actor and the actor location to be the location.

Then lastly it sets the material.

Yeah. It just doesn’t change even though the locations are the same. And I even made a bool to set to true if they are overlapping. It does get set to true but the material still doesn’t change for all objects. It only changes for the most recently spawned object.

Hmm, yeah this is one of those things where’d I have to check it out ya know.

As for the overlapping actors, it should certainly work, and doing it that way should affect the loading/saving. The only issue is changing materials, right?