Download

Impossible to decrement in a For Loop Body?

Hello all!

So within my for loop body a function is called, within that function I try to decrement a certain Integer. This doesnt seem to work tho, looks like the for loop is to fast or something? I can not really explain. I tried to do it outside the function but still within the loop body. Still does not work.

So I wonder, is it impossible to decrement/increment values in a for loop?

Thank you for all answers!

BR

If the value your modifying is part of the for loop (first/last index var), then no.

Post a screenshot of you logic flow and give us some details on what you’re trying to accomplish (purpose of loop).

Hello Rev0verDrive,

thanks for your reply. I deleted the initial code already but here I quickly rebuild the idea behind that:

The goal was to spawn 6 actors in total (amount stored in the array “Amount of actors to spawn”, I would have different values here for different waves)
But not 6 of the same type (Different actors defined in the array "Actors to spawn) so after the first 3 actors are spawned, the branch should switch to false which would change the index of the “Actors to spawn” array.

I thought of different ways already, but it would be great to know why the decrement is not working :slight_smile:

Big thanks!

Yikes! There’s no need to change the variable, the loop does that for you, that’s the point.

I’m assuming you’re doing a sort of ‘amount to spawn’ / ‘type to spawn’ thing there, in which case:


I mean:

@Zvenzo

I think this is what you want.

The problem with the way you were trying to decrement is you were attempting to modify a “get reference”. The Get reference isn’t a defined variable.

The return index value increments with each loop … 1,2,3 etc. Use that value for count conditionals … Index == current iteration int.

The above will spawn the first 3 as type 0 and all remainders as type 1.

Dear Rev0verDrive,

thank you good sir. This answered everything for me!

<3