Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

186
Views
How to react with a single member of a group

I have a bunch of snowmen. They are all tween. When a player is captured by a specific snowman it is carried by it.

It is messy, inconvenient and time wasting to create every single sprite and set it to tween. I have learnt to use

const snowman = this.physics.add.group(); snowman.create(x, y, 'key');

But this does not give each snowman a name. When I set the player's X and Y when it is being carried, I set it to the x and y of the snowman that hit him. If I use the code above, it will obviously no longer work. What can do instead?

enter image description here

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Well without knowing your code. I would:

  • Create a variable to mark the snowman, that captured the player
  • and when the player collides with one snowman, set variable. Like this you know which snowman.

in the create function:

function create(){

    ...
    this.mainSnowMan = undefined; // at the begining no snowman is selected
    this.physics.add.collider(player, snowman, (player, currentsnowman) => {
        ...
        this.mainSnowMan = currentsnowman; // set the snowman that collided with the player
    });
    ...
}

documenation to the collider function https://photonstorm.github.io/phaser3-docs/Phaser.Physics.Arcade.Collider.html

and here is a link so man phaser physics examples: https://phaser.io/examples/v3/category/physics/arcade

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!