Add array is not working, the array does not add and stays at 0

2


I am making a summoning system where the player uses a spell to summon an AI to help them in combat, I got that part working.

My issue is I cant seem to set a limit to how many they can spawn, I only want 2 max. I am using the following code in the pictures to achieve this.
The array is not going higher than 0, every time the players casts the spell and its successful, it should +1 to the array so I can limit the amount they can spawn.

I have tried addunique and add array but neither work as intended. Not sure what to do, any help is appreicated! :slight_smile:

I should also mention it is adding a BLUEPRINT to the array, e.g. my AI. Not sure if that affects anything

Each one of the AI will have a distinct actor reference. So add unique will always add, because all the references are different. The array will be growing in size, I assume your code for checking that is a bit buggy somewhere.

Why not just count the number you’re spawning?

I am horrible with this sorta stuff, what would you recommend?

If you don’t need the AI refs, then just count how many you’ve spawned

If you do, then stop when the array is too big

1 Like

The AddUnique node does not return the array length, it returns the index of the newly added element.
So if it prints 0 after the first summon, that’s expected.
Does it always print 0 even after several consecutive summons?

1 Like

Yes its always 0, yeah I did a little research into the add array nodes and add unique should make it 0. So you are correct :slight_smile:

Neither of these work, add or add unqiue prints 0 non stop (so infinite spawn)
Increment adds 1 then stops counting, meaning if I want two max minions, it will be infinite spawn too

Both of them definitely work. Can you show the whole piece of code?



Thats all I got so far

Looks ok, what is ‘max count’ set to ?

2

Changing that number does nothing either, tried 1 as well :\

Changing to one prints my print string no more and does not spawn any either, I should add the variable does work, just with nothing higher than 0.

And what’s happening? You’re getting none, or too many or?..

Sorry if set to 0 none spawn. if set to 1 or more it will infinite spawn

Basically I only want 1 or 2 max, I want to be able to change that number in the future. But for now I will be thrilled to only be able to spawn in 1 AI. No more. Just for testing purposes

When it spawns an infinite amount, the print string HAS to keep increasing. It’s impossible, it can’t. You must be spawning them elsewhere…

Sorry I mean, every time I cast my spell 1 spawns. Only 1. But I can recast and spawn another 1. Even though my interger is set to only spawning 1 max. Every new cast will always spawn additional AI, one at a time

They only spawn via my spell. Ill try look into my magic system to see if there is something there, thanks for your help anyway mate :slight_smile:

1 Like

Do you see the counter going up forever? The print?