How work method iterate for group

Can’t understand how work method >iterate< for group.

I want get property of the object in Set structs like this:

group.children.iterate((child) => {
console.log(child.y); // It’s work, in console I see position of the gameObject

But, this code does not work

group.children.iterate((child) => {
if (child.y > 1000) { console.log(‘Show error’); }

It throw error in console: can’t get property ‘y’ of the undefined.

How I it understand - any expression does not work… Why? It something special in work Set structs?

Sorry, this not full information. I find my problem. Full code looks like this:

group.children.iterate((child) => {
if (child === undefined) return;

    if (child.y > 300) {
      group.remove(child, true, true);


1 Like