Pick ONLY Top instance for each in Family?

  • Hi All,

    I still don't know how to setup a working UID or use it when CREATING a new instance (I don't get it yet).

    So, I tried another way using For Each instance in a Family.

    The effect I want works as I need but it won't enable ONLY the Top Instance but also the any instances Top & Bottom, basically any instance that the mouse cursor is over.

    How can I fix this without using the confusing UID way of code?

    I attached a file if anyone can have a look, Thanks ahead! :)

    DOWNLOAD - Construct 3 Example File

  • Why use For Each here?

    Imagine you're running your code on a stack of paper. 100 sheets.

    For Each: You pick up the stack and select a single sheet of paper. This is the sheet you're going to run the rest of the code on. (You will do this for every single sheet of paper in the stack, one at a time. This is what For Each means)

    Pick Top Instance: You look at the sheet of paper in your hand and check to see, out of all the sheet(s) of paper in your hand, which one is on top. Since you only have one sheet in your hand, the top instance is automatically the one in your hand. This is why your code doesn't seem to care about what's on top and what isn't. To your code, every single sheet is on top because it's only being compared against itself

    Here is one way you could do what you're trying to do:

    This basically deselects ALL objects every tick, and then only selects objects that are both:

    1. Being hovered over by the mouse

    and

    2. Are at the top of the stack being hovered over by the mouse

    Let me know if you have any questions!

  • Thank you for the helpful explanation, I do understand your description but when it comes to C3 I get confused real fast but I'll try to get the idea as I'll keep practice, for now I feel like I do some random organized with some actions which feels really bad because I do want to understand so I can be more creative.

    For example, I used your screenshot, which I didn't even THINK about making an empty event for the "Disable Outline" action, such a simple solution which my brain can't solve inside C3.

    Now that it works, when I drag the selected instance it enables the OUTLINE effect as I wanted but...

    as I keep dragging it OVER other instances, they are also enable the OUTLINE, and I want ONLY the dragged instance to be affected by the effect (one at a time, that's why for each made sense to me because how it sounds... for each instance.. but I see, it's not how it works)

    How can I make this to affect only one instance, even while dragging and not just by over with the mouse cursor (2 different goals for the OUTLINE effect).

    Feel free to show me a screenshot like you did or use the example file I uploaded on the first post.

    Thank you so much kidswithcrowns for taking the time to explain and show a visual example which helps a lot to my simple-logic-brain :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Alon

    Here's your problem:

    you want to make an outline for the currently hovered-over top instance of an object BUT only when another object is NOT being dragged

    So I would take the code that handles making an outline (the one I showed you) and add some sort of condition that means "only when another object somewhere is NOT being dragged" so that the code has boundaries of when to activate and when not to activate. This will be your "I'm not dragging anything" outline code

    And then you can make separate "I am dragging something" outline code

  • Hi kidswithcrowns I guess I'm not that smart to figure this out,

    As I explained my problem is that my logic on paper is SUPER EASY for me to understand but as soon as I try to translate it to C3 code... it's a total mess.

    Here is what I tried to do following your instructions, which is not working because I probably didn't get it right... again:

    DOWNLOAD - Another Failed Try C3 file

    Thanks ahead for any help! :)

  • Hi kidswithcrowns I guess I'm not that smart to figure this out,

    As I explained my problem is that my logic on paper is SUPER EASY for me to understand but as soon as I try to translate it to C3 code... it's a total mess.

    Here is what I tried to do following your instructions, which is not working because I probably didn't get it right... again:

    DOWNLOAD - Another Failed Try C3 file

    Thanks ahead for any help! :)

    You're definitely smart enough Alon! You just have to mess around more until you figure it out

    I looked at your example. Great work, you're on the right track

    Take a look at this part:

    "Created_Object is NOT DragDrop Dragging" almost works but you have to remember it will still pick all the Created_Objects that are not currently being dragged, even if there is one that IS being dragged! So you need some sort of method of being able to check if ANY of the Created_Objects are currently being dragged

    I recommend 3 things to try playing around with to make this happen:

    On DragDrop Start >

    On DragDrop End >

    Global Instance Variable (Boolean)

    Good luck!

  • First of all Thank you so much for your encouraging words and mighty patience with me...

    Still, I don't think that my brain can handle C3 very well, and I'm scratching my head:

    "IT IS SOOOO SIMPLE when I think about it logically, this is ON, that one is OFF while this happen, and this is NOT happening etc.." same story, C3 Code = MESS! I'm losing my mind how can I stuck on the most basic things in C3 this is why I said I'm not smart enough, not stupid.. but not THAT smart, I just face reality not just saying it for nothing.

    Anyway...

    I just made the code much longer now with the new ON/OFF Switch I hope that it's ok that I used instance variable for the Family instead of Global Variable, does it matter? (I'm not sure) the reason is for organized sake, nothing more. if it's an issue I will make it a Global Variable of course.

    But that's not the problem, now what I got is that it's working... kind of again.

    The dragged instance will be the only one to enable the OUTLINE effect, but... it won't if the cursor is over (without dragging) which I tried to make another event for the "Cursor is Over" but I got bad results so I just deleted it.

    Also, I believe that I didn't need the "Outline_ON" Boolean for the current code, I just made the code longer for nothing, it's the same thing... with more lines. (this is what I meant I make a mess hehe).

    I know that the problem is not in my logic thinking, it's on trying to take my logic thinking and translate it to C3 code... this is where I feel useless and my code looks like a guessing mess.

    So my feeling is that I need extra event for the "mouse cursor is over" but as I said.. it only made even more mess so I skipped it to show you the current mess.

    Sorry to failed you once again Master kidswithcrowns unfortunately the longer the code gets the more confused I get even with comments (this is why I like to separate things to Folders, beside the fact that I can use them to enable/disable which is one of the features I really like in Construct.

    DOWNLOAD - Another Failed Test

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