I need help getting the location of a component from an array of actors.
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!
answered Sep 05 '14 at 07:37 PM
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.
answered Aug 28 '14 at 01:09 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here