How do I pickup, carry and release ONE object from a group

  • I am doing something similar to when in the zelda series Link has to carry a chicken and release it in a certain area. i have everything set and working, basically, when the player sprite overlaps the object and presses a key, the object gets pinned to the player until a key is pressed and the object is released.

    the only problem is that if i happen to be overlapping two instances of the same object it picks up both, i need it to be so a player can only carry one object at a time

    Thanks in advance

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • In the "Is overlapping" event create a sub-event "Chicken pick top instance" or "Chicken pick closest instance" and then pin it.

    And of course you need to set some variable or instance variable (ChickenPickedUp=true), so then other overlapping events will be ignored.

  • NIce, first part is working flawlessly, does the variable need to be used as a conditional to pick the object? if variable=false pick up object? > change variable to true?

  • Yes. Or you can add it as a second condition to "is overlapping" event.

    Player is overlapping chicken

    variable=false

  • i must be doing something wrong, right now the conditions are:

    On E pressed

    X is PickedUp

    player sprite is overlapping the objects sprite

    |

    |

    |________>object>pick nearest to (player sprite.x, player sprite.y)---> and then the actions among which is toggle PickedUp

    it keeps picking up objects even if it's carrying one already.

  • Run your project in debug mode, see what's going on with PickedUp variable.

    Instead of "toggle" try "Set PickedUp to True".

  • You are setting instance variable pickedUp on a slime! Each slime has its own pickedUp variable.

    When you pick one, its variable is set to true.

    The next time your character is overlapping another slime which has pickedUp=false, that's why you pick up the second slime.

    You should create a boolean variable on the character (Sprite2).

  • you rock man

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