UPDATED: The logic/code below is working fine… what I found out is that all my instances of this BP have their variables set to the “default value” and not what i set in the details panel (I set them to expose on spawn).
I have the code below in my Blueprint. It was working just fine and then suddenly just stopped working. The >= comparison ALWAYS returns false. I didn’t change anything, it just started doing it.
I have this exact code in two BPs. In one it works fine, in the other it fails. Any idea why this could be happening?
It doesn’t fail. There’s something wrong with your logic.
Get components by Tag
→ Length > 0 Branch [true]
→ Loop
If Array length == 0 array index is -1
Nothing wrong with my logic. I figured out what is happening, but still don’t know why.
Suddenly my “expose on spawn” variables are not populating. They are all resetting to the default value rather than what I have in the instantiated object.
Nothing wrong with my logic. As I mentioned, works fine in another blueprint that does the exact same thing only with a different mesh orientation.
I’m telling you, run a length check on the Get components w/tag result. If it’s 0, then the loop will output an index of -1.
-1 is not > or equal to 0… 0 being the first possible index returned from the loop.
Im telling you that you are wrong. I changed the default value to 5 and the function is working just like it is supposed to. So all of the logic is sound and this works just fine.
I found the problem and it looks like its one others have run into which is that for some reason, this blueprint is now ignoring the values I put in the details panel when instantiating this Blueprint. If I change the default value, i can see it ripple through and this logic works like it is supposed to.
I can also manually add the values with a custom event on begin play and everything works just like it is supposed to.
I just need to figure out why this is happening and how to fix it. I’ve never had this happen before. its the same as this post:
BP: Spawn Actor doesn’t use expose on Spawn variables - Development / Programming & Scripting - Epic Developer Community Forums
I’m just telling you that if you run a loop on an empty array the >= will always fail.
That’s all I’m saying.
screw ups in your other BP’s is not what I’m referring to.
Thanks - I appreciate that guidance to ensure that doesn’t fail. But it doesn’t solve my core problem which is that my spawned actors are not picking up the exposed variables I set.
I made a copy of this BP and created another one and I’m guessing that somehow broke something. I’ve found a bunch of posts on this but no resolution.
What you are referring to is an old bug. circa 2015 /2016.
I have 9 engine version installed that I work with routinely. Spawning a lot of actors and never run into this issue.
I’m in 5.6 now running a test on it.
This is working perfectly in 5.6
If you want to see a video demo of it let me know.
Do me a favor and run a length check on the get components w/tag
results. If false print string.
I have done all that - I did a very simple test… I put a very simple “Print string” on the event begin and it is showing the default value, not what is in the details.
As I said, this was working perfectly fine until I duplicated the BP and then the original one just broke.
So here is where I am instantiating the actor via my blueprint in the viewport - you can see I have put values in the “default” section:
But as you can see, when I have the BP print out its values, they are the DEFAULT, not what was put into the details panel:
UNBELIEVABLE… I figured it out. I don’t know how this happened, but apparently when I duplicated the BP, it WIPED OUT the Child Actor Class from the Child Actor Component.
I fixed this and everything is working again.
And there you have it. Get Component w/tag
was returning 0 results.
Would you PLEASE STOP. No it wasn’t.
I was getting a full array set (23 in length). What was happening was my exposed variables were not being passed so the values were wrong which caused the logic branch to always fail. It was iterating through the array and all of its components just fine…