How do I delete/destroy single object?

0 favourites
  • 7 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • Hey there!

    I decided to take a couple days and refresh myself with the tutorials and review a few of the games others have submitted (seriously some talented people on here!)

    With that said, I'm trying to understand how to delete/destroy an object using the UID (maybe it's not possible, don't know). For this example, I have 3 building blocks (sprites) that provide the player the option to build an oil pump or coal mine. Each block can be something different.

    Once you build it, if you want to switch to something else, you have to first destroy it and then choose what to build there. I've got the building part down but not the destroy. I assumed it would be similar commands but I'm missing something. Any help would be appreciated.

    (There is a global variable at the top called SelectedID = -1

  • Are coal mine and oil pump members of the Minerals family?

    I think you need to change the last event on your screenshot like this:

    Button on clicked
    Block pick instance with UID SelectedLocationUID
    Minerals is overlapping Block
     Minerals destroy
     ...
    

    Also, it's not very efficient to re-create the buttons all the time. You can build the whole menu on the layout with hierarchy, and created/destroy it with a single action.

  • Either remove the block is overlapping minterals or add a pick all block before pick by uid in the last event.

  • Thank you both! Almost done for the day and can come home and test out these suggestions. I appreciate your help!

  • Either remove the block is overlapping minerals or add a pick all block before pick by uid in the last event.

    Thank you for your time and help!

  • Are coal mine and oil pump members of the Minerals family?

    I think you need to change the last event on your screenshot like this:

    > Button on clicked
    Block pick instance with UID SelectedLocationUID
    Minerals is overlapping Block
    Minerals destroy
    ...
    

    Also, it's not very efficient to re-create the buttons all the time. You can build the whole menu on the layout with hierarchy, and created/destroy it with a single action.

    Makes me happy/frustrated you saw the fix so quickly. Moved the code around to match what you had and poof! It worked. Thank you so much!

    Also, the menu with hierarchy is a little ahead of where I am but will look into it next. Of course expect a question in the forum from me when I do.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Seriously thank you both for your time and guidance!

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