Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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.

alt text

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.

alt text

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.

alt text

alt text

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.

Product Version: UE 4.9
foreach1.png (843.6 kB)
foreach2.png (860.2 kB)
checklocations1.png (116.6 kB)
more ▼

asked Dec 10 '15 at 09:47 PM in Blueprint Scripting

avatar image

7 3 3 7

avatar image vanlacke Dec 10 '15 at 10:06 PM

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?

avatar image J_Issa1 Dec 10 '15 at 10:28 PM

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.

alt text

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.

alt text

Then lastly it sets the material.

placeobject1.png (106.2 kB)
placeobject2.png (131.9 kB)
avatar image vanlacke Dec 10 '15 at 11:01 PM

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?

avatar image J_Issa1 Dec 10 '15 at 11:03 PM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question