ErikSwahn's Recent Forum Activity

  • Thanks! I missed the detail that I had accidentally used the object and then the family. Will try changing that and come back if the problem persists.

  • I will not use on collision since the player must press a button to pick up an item. Anyway, here is a screenshot. Thanks in advance!

  • The player can pick up items on ground. When picking up an item, it is destroyed and an empty item slot, picked from the left gets the name of the item. However, if 2 items are overlapping the player, both gets destroyed but only 1 item slot is used.

    How can I make sure only 1 item is picked up at a time? I have tried using pick nth instance and pick random instance with sub events but it does not seem to make a difference. The player is a single object and the items belong to a family called "items".

    My current logic:

    player is overlapping items

    interact=1

    itemslot1=empty

    itemslot2=empty

    itemslot3=empty

    trigger once

    -sub event-

    pick nth instance=0

    -sub event action-

    set itemslot1.name name=items

    destroy items

    As said it works fine as long as just 1 item is picked up at a time.

  • I actually tried another method and used the "Pick nth instance" condition for a subevent after the overlapping event which let me pick each item specifically to check their names. It seems to work well so far. Just thought you might know.

  • Thanks :D

  • The item is actually a family. So is there a way to check each instance of the family separately?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The player can drop items. If 2 items collide they should make a new item. The items have a name variable telling the game what they are. How do I check the name of each one separately before deciding what to do when they collide?

    If item is overlapping item

    item 1 name is "STICK"

    item 2 name is "STICK"

    Then destroy item (both of them)

    Then spawn item and set name to "CLUB"

    I have tried sub events but it does not seem to work. I might have done it incorrectly since I am not 100% sure how to structure them though.

  • You do not have permission to view this post

  • > The swapping already works. This was tested before the system got more complex.

    >

    > However I will take your advice and make a check when something is picked up and run the loop afterwards. I will also try "else" to check if all slots are filled.

    >

    > Thanks!

    Oh okay, what isn't working?

    I figured out another way to solve it. If player overlaps an item and picks it up the item is destroyed, preventing actions further down the code. So I just placed each event in order in the sheet starting with if itemslot=3 then itemslot=4 etc.

    Like this:

    If player overlaps item

    Picks up

    itemslot=3

    itemslot=empty

    -set itemslot filled

    -destroy item

    If player overlaps item

    Picks up

    itemslot=4

    itemslot=empty

    -set itemslot filled

    -destroy item

    If player overlaps item

    Picks up

    itemslot=5

    itemslot=empty

    -set itemslot filled

    -destroy item

    Since the item is destroyed when one of these are true it simply stops the next event since the player is not overlapping item anymore.

    After these events I replaced the =empty with =filled and repeated the events but adding the replace actions.

    This works nicely since I will not have more than a maximum of 6 itemslots, so code won't be too long. Just thought I'd let you know how I solved it.

  • > The swapping already works. This was tested before the system got more complex.

    >

    > However I will take your advice and make a check when something is picked up and run the loop afterwards. I will also try "else" to check if all slots are filled.

    >

    > Thanks!

    Oh okay, what isn't working?

    I have not tried it yet since I must take a break and sleep. I am back at it tomorrow :)

  • Could you just have 3 global variables

    On pickup.

    Check slot 1.

    If global variable=0 then set global variable to uid of object picked up. Else check pickup2. Else check pickup3.

    The 3 slots will have uids set to them. And you can choose any object base on its uid

    On drop, just set the slot global variable to 0 again

    That sure is smart but I currently use instance variables for objects. Will try the "else" method later but must sleep first. Thanks for the simple idea :)

  • The swapping already works. This was tested before the system got more complex.

    However I will take your advice and make a check when something is picked up and run the loop afterwards. I will also try "else" to check if all slots are filled.

    Thanks!

ErikSwahn's avatar

ErikSwahn

Member since 15 Jul, 2014

Twitter
ErikSwahn has 1 followers

Trophy Case

  • 10-Year Club
  • RTFM Read the fabulous manual
  • Email Verified

Progress

12/44
How to earn trophies