Comparing Multiple Instances of Objects

This forum is currently in read-only mode.
From the Asset Store
Be quick and choose the right answer for the shown equation.
  • Hey Guys,

    I have multiple instances of an enemy and multiple instances of a sprite called Enemybox. Enemy and EnemyBox both have a pv called '#' which i use to set their positions.

    +EnemyBox: pick by EnemyBox('#')=Enemy('#')

    -EnemyBox: set position to enemy

    And then when the player goes into an Enemybox i want the Enemy (with the same '#' as the Enemybox) to set a pv it has called 'target' to 1, so i use

    +Enemy: pick by Enemy('#')=EnemyBox('#')

    +EnemyBox: overlaps player

    -Enemy: set 'target' to 1

    But when i do this it makes only 1 random instance of Enemy anywhere on the layout target the player. Can someone please help me?

    Thank you.

  • Always take care of the order. In your example, no EnemyBox was picked when trying to pick an enemy. So CC looks at the value of the first instance of EnemyBox. Only after that the correct EnemyBox is picked.

    Instead of the "pick by" condition, you can use the "compare private variable" condition. It was designed for such a task.

    + EnemyBox: overlaps player

    + Enemy: Value '#' equal to EnemyBox('#')

    -> Enemy: Set 'target' to 1

    In most cases this should work.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Well that worked so thank you :)

  • I'm sorry this is late but your reply didn't solve all of my problems. sometimes when one Enemybox is triggered it will mess up the other Enemyboxes. Here is a cap that that shows what I'm basically trying to do.


Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)