[SOLVED] How to make each instance of object do a thing independently

Link to the playable demo of the problem: ExampleCollision | Play on Liluo.io
Link to the playable SOLUTION: Liluo game build

The goal is to make

  • the RED box (has “Id”=1) automatically rotate ONLY when ITS stick is inside a wall
  • the BLUE box (has “Id”=2) automatically rotate ONLY when ITS stick is inside a wall

I guess the concept I have to tell the game is that when any one instance of the object meets the conditions then things must happen only to THOSE instances who meets the conditions. How can I do it?

This is the code I’m using:

EDIT: as asked here’s also the setup: the box is a white sprite, and each instance of it has a variable with the color it has to have. An effect picks this value and tints each instance.
The boxes and the walls have Physics 2.0 behaviour.

Hi, for everyone in the forum to better understand the situation, could you provide the other events and also explain how the box is set up (you have a blue and red box in the scene but in the event snip the box is white)?

Ok, updated the question. (The box is a white sprite, and each instance of it has a variable with the color it has to have. An effect picks this value and tints each instance.
The boxes and the walls have Physics 2.0 behaviour.)

Just a quick thought: you could try to use a boolean variable that is being set to true (in your case when the variable Id of Box = 1). The true-state of this variable would be the additional condition in the “stick repulsion”-event to make sure that the torque is not applied to both boxes.

I’ve found a solution: Liluo game build
I have embedded the “stick repulsion” event into a “for each” instance of Box element.

I have to thank you for your time, and also because I thought of the solution by replying to you.

1 Like