hi everyone. I’m trying to create a sort of random placing of rooms in my game, but i’m probably making something stupid. If i don’t use for loops and just try one random from the list, it works, but using for loops or doing 2 in a sequence keeps throwing me these errors(from my debugging i guess it means the results from the array are null)
i have currently 3 levels in the level array and 3 possible random spots(those are actors picked in the persistent level) where each room could spawn(so i am trying to use a for loop to iterate through each one of the levels in the array and choose a random spot.
another thing i noticed, is that no matter what when using the random integer, i never get my index 0 result from the array.
Hoping some guidance here. thank you very much.
thank you for your reply/ I was under the impression if I use a “length” instead of the last index(as i was not using last index) i don’t need to do the -1.
it throws out less errors, but still gives me this error
Play in editor start time for /Game/Levels/UEDPIE_0_Proceadural_Grid_Persistent_Level 0.465
Blueprint Runtime Error: “Accessed None trying to read property CallFunc_CreateInstance_ReturnValue”. Blueprint: Proceadural_Grid_Persistent_Level Function: Execute Ubergraph Proceadural Grid Persistent Level Graph: EventGraph Node: Set
Blueprint Runtime Error: “Attempted to assign to None”. Blueprint: Proceadural_Grid_Persistent_Level Function: Execute Ubergraph Proceadural Grid Persistent Level Graph: EventGraph Node: Set
Blueprint Runtime Error: “Accessed None trying to read property CallFunc_CreateInstance_ReturnValue”. Blueprint: Proceadural_Grid_Persistent_Level Function: Execute Ubergraph Proceadural Grid Persistent Level Graph: EventGraph Node: Set bShouldBeLoaded
Blueprint Runtime Error: “Accessed None trying to read property CallFunc_CreateInstance_ReturnValue”. Blueprint: Proceadural_Grid_Persistent_Level Function: Execute Ubergraph Proceadural Grid Persistent Level Graph: EventGraph Node: Set bShouldBeVisible
Thats Strange. When i’m Not wrong, lets say in an Array with 5 Elements length should Print you 5 and lastIndex 4. So you should use -1 or lastIndex. But you can Doublecheck with a Printstring.
Add a isValid after the createInstance and in the Fail Node Connect Something Like a Printstring and Set a Breakpoint. When it Hits that Error, Check your variables in the BP (ints/Index/Array). If you don’t find a Thing temporarily disable the random Logic and Just Check in the forLoop that EVERY Level in your Array works.