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"

I need help getting the location of a component from an array of actors.

im having trouble getting the location of an mesh from an array.

the array is a static mesh component array.


Product Version: Not Selected
more ▼

asked Aug 27 '14 at 04:27 PM in Using UE4

avatar image

189 22 23 34

avatar image Ben Halliday STAFF Aug 27 '14 at 05:42 PM

Hey bennetherwood,

This should function the same way we discussed in this thread:


With the exception of using Get World Location (which accepts Components) instead of Get Actor Location. What trouble are you having getting this to work?

avatar image bennetherwood Aug 27 '14 at 06:18 PM

i have played around with this a bit and the array being generated isn't seeming to load correct information? all the actors i spawn from the location of the value in the array is 0,0,0 is this the default for an empty array?

avatar image Ben Halliday STAFF Aug 27 '14 at 06:25 PM

That's correct. It sounds like you aren't setting the values to your array properly. Can I see an image of your setup? What are you trying to use as your array elements? Are they components of the Blueprint creating the array?

avatar image bennetherwood Aug 27 '14 at 06:36 PM

i think it is because i am spawning actors from class on event begin play, then adding them to an array, then creating a master array in another blueprint ?

i will include a sample of how i add the vars to array because the graphs are huge

there are loads of BP for lots of different structures which are randomly spawned into a solar system BP

alt text

the main BP is then a galaxy BP which spawns a random number of solar systems, i can do my method of spawning a actor from class at a location from a var in an array no problem in the solarsystem BP but not in the galaxy BP, so i think this is the weak link, if 0,0,0 is the default if there is nothing in the array, i think that the problem is that there is no values in array in GalazyBP as they aren't carrying over from SolarSystemBP

(galaxyBP below)

alt text

thanks soo much for your help :D

untitled.png (390.1 kB)
untitled2.png (217.2 kB)
avatar image Ben Halliday STAFF Aug 27 '14 at 06:51 PM

So you have a GalaxyBP, which spawns SolarSystem BPs, which spawn planets, in that order? Or are you creating the SolarSystemBPs and then using the GalaxyBP to collect them?

avatar image bennetherwood Aug 27 '14 at 07:02 PM

i belive so, yes, the galaxyBP spawns solarsystemsBP, which spawns planetsBp (and a sunBP, which i think is irrelevant)

i have 1 instance in game of GalaxyBP ingame and it creates the galaxy on event begin play

this is the 1st part of graph, youve got the 2nd (event begin play)

alt text

this is the spawning event on the tick action

alt text

untitled.png (213.8 kB)
untitled.png (123.3 kB)
avatar image Ben Halliday STAFF Aug 27 '14 at 07:14 PM

And the Get World Location in that last image is the one spawning Actors at 0,0,0? I'm going to set up a smaller version of what you have here to see if I can locate the source of the problem, but you have a lot more that I can't see in these images so I may have more questions. I will let you know what I find.

avatar image bennetherwood Aug 27 '14 at 07:26 PM

yes they spawn at 0,0,0 no matter what happens, i need to raise a big point now that i wasnt going to raise here as i thought it was a separate incident, im not 100% sure but i think i still got it without spawning asteroids, actually that when the asteroid (in last pic) is spawned i think for everyone (because ive not counted them all and checked against tick time) they cause this error


then i click on it and this shows

"assessed none "call func_array_get_item" from node construction script in blueprint galaxyBP"

i neglected to mention as my construction script is completely empty ?

avatar image Ben Halliday STAFF Aug 27 '14 at 07:45 PM

Yea, that error pops up when you use a Get function on an empty array.

avatar image bennetherwood Aug 27 '14 at 07:50 PM

so is it that the array isnt being carried across from the solarsysyemBP to be appended to make a complete list of all various things (planets, stars ect)?

avatar image Ben Halliday STAFF Aug 27 '14 at 07:56 PM

It's hard to say without being able to see it in action. Would you feel comfortable putting the project up somewhere and sending me a link so I can go through it? I want to help get your project working as you want but I also need to see whether there's a bug in here somewhere.

avatar image bennetherwood Aug 27 '14 at 08:05 PM

alright, but assuming that you are staff, then will the asset please not be distributed as its part of my game?

if so i would prefer sending it to a personal email rather than openly online.

avatar image Ben Halliday STAFF Aug 27 '14 at 08:15 PM

You can PM me on the forums with a link, or with any concerns about sharing the project. Yes, I am Epic staff.

avatar image bennetherwood Aug 27 '14 at 08:22 PM

how do i send it to you directly? i cant see the option on your profile

avatar image Ben Halliday STAFF Aug 27 '14 at 08:34 PM

There isn't one. Message me and we can talk about how to get me the project.

avatar image bennetherwood Aug 27 '14 at 08:39 PM

yer thats what im saying how do i message you directly?

avatar image Ben Halliday STAFF Aug 27 '14 at 08:42 PM
avatar image bennetherwood Aug 27 '14 at 09:06 PM

sent it man !

avatar image bennetherwood Aug 27 '14 at 09:08 PM

ow and you can delete high floor solar in simulation whenever its spawned because it gets in the way of seeing asteroids

avatar image bennetherwood Aug 29 '14 at 08:15 PM

ive tried your method of getting loctations from get all actors from class, if i do the following in galaxyBP it doesnt work but if i do it in solarsystemBP it works???


do you thing it could be an issue with vars not being passed from from a soawned Bp in a spanwed BP?

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

2 answers: sort voted first

Hey bennetherwood,

I was able to speak with one of the developers here, and found a workaround for the issue here: in your GalazyBP, put a Delay node after the Event Begin Play, and set it for something tiny (.001 or whatever). Now your BPs should work the way you expect!

It seems that the engine needs to finish initializing everything in the level at begin play, and so it's trying to initialize each SolarSystemBP together. By adding the delay, everything is initialized before the For Loop begins, and it's able to process each Spawn individually. It has something to do with Actor lifetime, and I'll admit that much of it is over my head, but my understanding is that this isn't something that can be fixed without breaking many other things. It should be possible to do with C++ but not with Blueprints, as Blueprints interprets Begin Play as the beginning of life for Actors.

Anyway, the project as you gave it to me should work the way you need it to if you include that brief Delay after the Begin Play node in the GalazyBP. Please let me know if you have any trouble with it after that!

more ▼

answered Sep 05 '14 at 07:37 PM

avatar image bennetherwood Sep 05 '14 at 08:19 PM

thanks man but i actually figured this out whilst you were away, i noticed that they spawned at 0,0,0 for a while and then at the desired locations, i did it this way. alt text i also noticed that i can see to get values from this method that didnt work before, maybe an accidental bug fix ?? (in 4.41)

alt text

also does adding a delay after an event tick help with peformance because the execution just stops or does it still put the same workload on the system?


untitled.png (220.1 kB)
untitled.png (259.1 kB)
avatar image Ben Halliday STAFF Sep 05 '14 at 09:55 PM

Yup, looks like that's another way of doing the same thing.

It still might be better to use the setup your originally had and just add the Delay after the Event Begin Play node. Even with a Delay, the engine is processing everything per Tick. For best performance in general, it's best to avoid using Event Tick when at all possible.

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

Okay, I spent some time debugging your project and spotted a few issues.

First, it looks like the Return Values from the SpawnActor SolarSystemBP_C node are not updating in the GalazyBP. So when your HighFloorScale variable is multiplied by 160 to update the LastSystemBounds variable, it's returning 0. That, in turn, means that when you multiply that with anything and then set that as your next SolarSystemBP spawn transform, it will always spawn at 0,0,0.

This looks like a bug. I can't see any reason the spawned Actor isn't returning the proper values. I'm going to dig into this a little further and talk with the developers to see if there's a reason for this or if it is truly a bug that needs fixing. I will let you know what I find out.

The way I was able to fix this was to update each of the variables that are currently after the SpawnActor SolarSystemBP node (Last System Bounds and each of the Arrays you're appending to) by casting to them in the SolarSystemBP itself. After each Set HighFloorScale node in the SolarSystemBP, cast to the GalazyBP and grab the variables you need and update them there. It's easiest to create a function for this and just use that in each of those three spots.

But you'll still run into an issue with spawning at 0,0,0 for an entirely separate issue: floats have a maximum cap, and you're reaching that when you multiply the GalazySpawn and LastSystemBounds variables to get your Spawn Transform. I saw the potential product reach over 11 digits, and I think the cap for floats is 10. So when you multiply these two huge numbers together, it seems to be converting that to 0, and you have the same problem as before.

I'm going to double check with some programmers tomorrow to see what the actual float cap is, and whether this should be converted to 0 or if it should truncate it. Either way, you might need to start using much smaller numbers (or integers, which I believe have a higher cap).

The third thing I noticed is that your For Loops tend to start with First Index 0, and then you pass it a desired number for the Last Index. I'm not sure if this is intentional, but I figured I would point it out. For example, for your NoOfSolarSystems check, if the number given is 4, then it will actually spawn 5 SolarSystemBPs because it starts with number 0 and then goes up to the number you gave it.

I'll keep looking into this, but you can try these workarounds (lowering the number scale you're using, moving the variable updates to the SolarSystemBP) in the meantime to keep your project going. As for the 'Call_Func_Array_Get_Item' error, I wasn't getting it at first but as soon as I messed around with the Arrays I started getting it. I'll ask a developer about that, but since it doesn't seem to actually affect the game it might not be a problem.

more ▼

answered Aug 28 '14 at 01:09 AM

avatar image bennetherwood Aug 28 '14 at 10:25 AM

Would it be possible to get a copy of the changes to my BP view Dropbox ? Im trying to recreate the way you solve this but I don't understand how you are casting ? Would really appreciate :D

I dont think for asteroid spawn the max float range is being reached though because if you see in SolarSystemBPWorkwithArrayInternaly The asteroids spawn, I agree that this wouldn't work if the last system bounds offset system worked but it currently doesn't

In my new setup i lowered scales a bit, but can still change the scale if needed, also another change with an observation

alt text

I noticed that If I add say 20000 alongside highfloorscale(which is systems size) to the last system bounds then it will only add 20000 each time, not the system bounds, so highfloorscale returns 0, this eliminates the possibility that variables are too large. it seems that any vars obtained from the spawn actor solarsystemBP doesn't save if it, but vars do save in solarsystemBP which are created from spawned actors ?

untitled.png (182.7 kB)
avatar image Ben Halliday STAFF Aug 28 '14 at 10:37 PM

Did some more debugging today and discovered the real source of the problem, and you're correct: you're nowhere near the float cap, so don't worry about scaling everything down.

The real problem is that each loop in a Loop macro happens per tick, but the Spawn Actor takes longer than that, so things are happening out of order. You set the value for High Floor Scale at the end of your SolarSystemBP, but the Loop attempts the next Loop Body before that value has been updated. This causes the value to equal zero until after all of the SolarSystemBPs have finished, meaning each is spawning in the same location.

I know that the developers are looking into this behavior with Loops, but my understanding is that it's not a small adjustment but a fairly complex fix that needs to happen before this will work the way we want it to.

I don't know a way to fix this for your project in the meantime, however. I'll give it some thought and experiment some more. Most likely you'll need to find another way to set the transform for the SpawnActor node per loop index. Anything you put before and after the SpawnActor inside the loop body will run before the SpawnActors start, so they won't be getting the correct information from its Return Value, either. For those array appends you're doing inside the loop body, you may need to wait until everything has spawned and do a manual count using Get All Actors of Class.

Sorry that this isn't the working the way that it should. Hopefully we'll get that fixed soon, but I have no timeframe for that yet. I will let you know when we do. Until then, I hope you find a workaround that's suitable for your project.

avatar image bennetherwood Aug 28 '14 at 11:31 PM

Alright thank you, at least we found this issue, I doubt I would have been found if I would have being doing something crazy like spawning a universe haha!

Am I right in saying that this is an issue but only when really pushing the engine because that lowers tick Rate?

Just to clarify is there no gaps in my logic then ? Because I've been trying to learn unreal for a while (back from udk :D )

This may also explain why the system works for spawning asteroids in solarsystemBP but not galaxyBP because the workload is much greater and thus the frame rate/tick becomes too low to effect setting array/vars?

I may have thought of a work around though, because the arrays and vars are the issue here with them not being set (thus no locations for spawns, and no ability to cast from other BP's after spawning an actor from class), there is no major issue with procedural content being created at a slower rate, can adding a delay behind each spawn either in galaxyBP and solarsystemBP or just galaxyBP (though i doubt that solarsystemBP Will need delays because it worked beforehand) this will raise the frames rate/tick when processing spawn actor from class, as there is a reduce workload on event begin play because the time taken to spawn actors/set vars or array is greater, just a thought ?

If this works I have an idea for partial implementation for your software engineers in that the editor can "scan ahead" of the spawn actor from class then check if the trigger event is an event begin play and automatically add the needed delay to rectify this issue.

However the above obviously won't work for tick event as it would cause gameplay problems/ apparent lag which isn't due to CPU/gpu/internet speed :(

avatar image Ben Halliday STAFF Aug 29 '14 at 12:27 AM

Unfortunately, you can't use a delay inside a loop, for the same reason: the loop body occurs each tick. There is a way around this by creating a custom macro that includes a delay, but I already tried that idea and the same problem exists. It seems that even with a delay embedded in a custom loop, the loop body still performs the spawn late.

It's not a frame rate issue, however, but a weird ordering of the loop body elements based on time to perform, I think. Even with a very simple setup that I made this afternoon, in which a blueprint spawns simple blueprint between two print strings, the spawn still happens last inside the loop. So this isn't a problem with pushing the engine too hard.

And as far as I could see, there's no flaw in your logic It's just a problem with loops inside UE4.

avatar image bennetherwood Aug 29 '14 at 12:35 AM

Alright man, just give us a bell when it's sorted, but why does that altered solarsystemBP which I gave you which spawns asteroids at random planets work then ? It sets arrays and adds to arrays after a spawn actor

Am I still right in thinking that the issue here is at galaxyBP and not solarsystemBP ?

avatar image Ben Halliday STAFF Sep 05 '14 at 06:04 PM

Sorry for the late response; I was on holiday and then spent most of this last week sick =/

The altered solarsystemBP didn't work in the project you gave me, but I didn't spend much time with it. The problems I saw happened with the galaxyBP and not the solarsystemBP, but I don't remember seeing a ForLoop inside the solarsystemBP and that was the root of the problem.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
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