How do I make events and actions target singular objects?

0 favourites
  • 2 posts
From the Asset Store
14 amazing sound files of game events like Level Ups, Level Completes, object spawn, object taking etc.
  • I have a door sprite and an invisible TriggerBox sprite for said door, the door sprite has 2 frames: Open and Closed. When the character overlaps the invisible sprite, it launches an event which sets the door sprite frame to open and plays a DoorOpen sound. The door stays open, and the sound only triggers once.

    All this works totally fine, but I have multiple instances of this Door/TriggerBox duo around my game; how do I make the event target the singular object that the character opens instead of all of them. At the minute, I'm testing it with two buildings that both use the Door sprite and invisible TriggerBox sprite for said door. But when I walk through one of them, it changes the animation frame for both doors.

    The "Animation frame = 0" is just to make sure the door stays open when opened.

    I thought that the "For each" event would actually do this, but I guess not. Any help would be greatly appreciated, thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That is a bitt a bizar construction.

    There are two thing to consider when using a condition.

    1/ The actions run if the condition is true.

    2/ The actions adress the picked objects.

    For 'each' picks an instance 1 by 1. If its animation frame = 0, it stays in the picklist, else it is filterd out. The overlapping condition does not filter anything doors out the picklist, the overlapping condition only makes the condition true or false. Conclusion: the action adresses each door with animation = 0, when character is overlapping any doorcollissionbox.

    You need to pair doorcollissionbox with its door. To do that, use a containetr. Or give Door and its Collisionbox an instance variable (say 'pair') that you gave the same number. So instance variable 'pair' of the first door = 1, and the instance variable 'pair' of the first collision box = also 1.

    Now you can ...

    Condition: On doorcollissionbox overlapping Character (picklist contains now that doorcollissionbox & character)

    Condition: Pick by comparisation ... Door.pair .. = .. doorcollissionbox.pair (add the right door the picklist)

    Actions .... whatever you need.

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