[UE 5] Blueprint - How can I get location value from add instance?

How can I get “location” value from “add instance”?


For example (Look at picture), I add an instance several times in a cycle, after its completion I need to find out the location of the last instance in order to call this cycle again but give a different number of iterations and a different location value for add instance. I need just variable in order to store the value?

Store all Instances you’ve created in an Array and retrieve location from the last index? Next loop can add Instances to the Array or you clear it before you start over …

How i can create array of instances? That`s right?Or i can even do without “make array”?

You can’t store instances, there’s no object return value, only an index.
However, you know the initial location and you know distance multiplier, you can create a new variable and add 360 to it with each created instance.

Sorry, I don’t have Unreal open so I’m guessing a little bit, but could you save the index of the last index you’ve created and then use the nodes in your last screenshot to get the location? Looks like it only needs an index input.

II think that I solved my problem, but I’m not sure how correct this is and whether there will be errors in the future, since my script is not completely ready. Attached a screenshot of the “solution”

Looks like you’re setting a location and immediately get the same value again to add 180 to the Y value.

But it seems that you can read the location value of each instance right after you’ve created one, so … you could at least store an array of locations to access them later on. Or my method in the last post should work, if you create some ‘counting integer value’.

But if your solution works for now, it may be enough. Hard to tell because the screenshot is quite limited with nodes … so, yeah. But I guess there are many ways to tackle such problems.

“add 180” it’s just a crutch, because I can’t use a loop with a condition, because I’m getting lost in exec pin

I’ll definitely check that stuff when I’m at my PC on monday and share my example BP.

So …

Seems like the Instanced Static Mesh Components come with some additional nodes we can use: Getting the Instance Count of the component and subtracting 1 because it starts with 0 gives you the Index for the last placed instance.

Regarding the ‘Add 180’: If you don’t mind to share the whole script you made we may can figure out any potential problems :slight_smile: