Hello,
I have made a physics group called poCars
. I have also made a game object with the name poCar
. I want to add the poCar
game object to the poCars
group, for collision. Everything works fine except that .setDrag(1000, 1000)
doesn’t work. Drag works fine when I don’t add poCar
to the group. I am using Phaser 3.22.0, with Arcade Physics. Here is a code example:
var poCars = this.physics.add.group();
var poCar = this.physics.add.sprite(7772, 48, ‘policeCar’).setScale(1.5).setDrag(1000, 1000);
poCars.add(poCar);
this.physics.add.collider(poCars, player);
The above does increase the scale of the poCar
but does not set drag. However, if you just simply comment out poCars.add(poCar);
and change this.physics.add.collider(poCars, player);
to this.physics.add.collider(poCar, player);
(Removing the s in poCars) the drag works again.
Is this a glitch or is there an issue with how I’m doing this? Can you think of a better way to call an overlap function when a member of a group is overlapping a player, and have each child of the group have drag?
One possible solution to this is to iterate over each child of the group and set its drag but I have not tried that yet. Should I?
I know that this is pretty long and confusing because all of the variable names are so similar, so if you have a question feel free to ask.
Thanks,
Ultimate Pro Grammer