Update arrays?

Hello!

I am trying to get an array based on an object location, but looks like the array is updated only on init. When the object location is changed, the array stills with the same initial value as if it were an variable.

Thanks in advance.

1 Like

That’s right. Because of the variable initialized, the array is filled once.

override function get(from: Int): Dynamic {
		if (!initialized) {
			initialized = true;
			for (inp in inputs) {
				var val: Dynamic = inp.get();
				value.push(val);
			}
		}

		return from == 0 ? value : value.length;
	}
1 Like

Hm. I think it is for optimization purpose, in this case what you think is better:

  1. Add a checkbox for “update” in each array node
  2. Add a Switch From Integer node and use the arrays just for static values

For now i will just replace the nodes position and it will work. Thanks!

I don’t know how much this helps in optimization, but it’s more logical if the array is always updated. But if you need to store values (as constants), then add a check mark (as you suggested in option 1, just the opposite).

You can also assume that you can ignore the value of the initialized variable, provided that the length of the array is 0.

1 Like