x

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"

Non-empty array returns length of zero?

Hi there,

I have encountered a weird issue with a function of mine that actually used to work before I upgraded to 4.19.2.

The part of the function of interest should get all instances of an actor array in the world. For the test, I only placed one instance in the scene. However, even though the array returns the one and only instance (instance zero), when I get the length, it finds that the length is zero, altough it should be one. How can this be? Even stranger is that appearantly zero minus one results in zero (??) and then then when zero gets plugged in into a getter from this array returns none (although instance zero should be there).

Please checkout the screenshot attached.

I am not sure if it is related, but another change in the version of the engine is that somehow I can't use the "get a reference" when I pulled from the array. Only get a copy is found. If I turn off context-senstive I can force to put in "get a reference" but then it is immediately converted into a "return a temporary copy". I am not sure if this is the cause, as in order to find the right instance a copy should suffice.

Many thanks for a hint.

alt text

Product Version: UE 4.19
Tags:
bild-083.png (142.1 kB)
more ▼

asked Oct 10 '18 at 03:14 PM in Blueprint Scripting

avatar image

BreakMaker
232 4 11 16

avatar image Pantong51 Oct 10 '18 at 05:07 PM

Have you attempted trying to save the array locally as a variable and see if it's 0/null there? I've had issues before where the array gets cleaned up or falls out of scope if I don't save it as a local variable if I don't use it as soon as I get it.

avatar image BreakMaker Oct 10 '18 at 05:34 PM

I will give this a try! I have worked with arrays in the exact same manner dozens of times (not saving the array) , and never had this problem. Maybe they changed something in 4.19...

avatar image BreakMaker Oct 11 '18 at 02:55 PM

Nope, it is not working even if I store the array in a variable. The length is still zero even though the instance sits there.

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

1 answer: sort voted first

I got it. So I managed to fix it by reparenting my blueprint actor to "actor". Previously it was a child of "target point".

It feels like a bug to me considering the fact that targetpoint (an engine class) belongs to the class actor (which is kind of obvious because you can place it in the world). But while in 4.16 this was no problem (and the same function worked there), here (4.19) the elements of the array did not seem to be valid.

My blueprint actor "spawn point" was created by placing a target point into the world and "clicking add blueprint / script".

So in case you experience something like this in your project where you cannot get instances of an array (even though they seem to be present in the array), then just checkout your blueprint or c++ class and try reparenting it.

more ▼

answered Oct 12 '18 at 01:31 PM

avatar image

BreakMaker
232 4 11 16

(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