objects.getChildren()

     var children = this.bullets.getChildren();

 this.physics.add.overlap(this.bullets, this.chicken,this.aa,null,this);
 if I add this in a for loop=>>>
  this.physics.add.overlap(this.chicken, children[i], this.abraham, null,this)
  It wont work, but overlap works in create function if i use group versus chicken.
   How I go about it if I want to check if a specific bullet overlaps, on chicken and then delete bullet?

Hey,

You should be able to access the individual bullets inside the callback, for example.
this.physics.add.overlap(this.bullets, this.chicken,this.aa,null,this);

// the aa function
aa(bullet, chicken) {
//the bullet that overlapped with the chicken
bullet.setActive(false).setVisible(false);
etc
}

Hope this helps :slight_smile:

2 Likes

yes, it works somehow but this.chicken is not defined somehow so the first bullet won’t disappear only after the first bullet disappears, why is that? is chicken or first bullet undefined>?
cheers =|

The age old question: What became undefined first, the chicken or the bullet?

Perhaps you could log both the bullet and chicken in your aa function to see which is undefined? Then ensure that the culprit is either disposed of properly or ensure that you’re passing in the correct parameters to the overlap function.

2 Likes

Its not saying its undefined per log but I built it like this in the class

chicken: monster
bullets: projectiles

and then in Create.
I add bullets and the chicken image and groups.
When I fire the bullets, 10 of the amount.
the first one never dissolves only the last 9.
So I just figured the first bullet is not correct anyway
I have no clue anymore
yes i will test the function
update: yes it console log correct objects, but it doesnt fire the first time anyhow i will keep testing

Maybe if I remake it to touching?
I have this code works. for some other task
children[i].body.touching.none ? console.log('miss'): this.dia.destroy();
basically, it gets the children of bullets, in an array and measure if it is touching anything. and the diamond goes black, how can I reconfigure it to only activate if touching the “chicken”
thanks for the help anyway =)