How do I pick specific objects inside a family?

0 favourites
  • 5 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • Hi again. I'm still working on my multiplayer prototype.

    I've encountered many times the problem of having to pick for a specific object inside a family, only to find Construct had chosen all the objects inside of it.

    I could managed to workaround many of these cases, but now I'm stuck trying to order the Z positions of the players vs the scenery.

    What I ended up coding works only when 1 of the players collide with the buildings of the scenery. But as soon other players collide other buildings, the Z order starts to get messed up. And that clearly shows I'm not actually telling construct which are the right objects to be picked up of both families.

    I've butchered the project only to have the bare minimum for you to help me evaluate the issue.

    The line 84 (with the marker) is where I set the Z of the objects.

    drive.google.com/file/d/1GyagGxVTqJ8dW5F5s6MIuPeVmxbJ1FUo/view?usp=sharing

  • When you are picking by UIDs in sub-events, you need to add "For each Buildings" loop to the parent "is overlapping" event. Otherwise your code will only work for the first building/player instance.

    I have two very simple demos for z-sorting, check them out:

    dropbox.com/s/lbewjvv6rekd2na/IsometricForest.capx

    dropbox.com/s/6num28c6nf9qhfb/ZOrderBuilding.capx

  • When you are picking by UIDs in sub-events, you need to add "For each Buildings" loop to the parent "is overlapping" event. Otherwise your code will only work for the first building/player instance.

    I have two very simple demos for z-sorting, check them out:

    https://www.dropbox.com/s/lbewjvv6rekd2na/IsometricForest.capx?dl=0

    https://www.dropbox.com/s/6num28c6nf9qhfb/ZOrderBuilding.capx?dl=0

    Thank you very much, Dop2000.... Can you believe that the same happened as the other day?: I figured out what you just said 20 mins before I got the email with your answer. Really funny.

    https://imgur.com/a/5cQemtA[/img]

    Again, that it's great because it tells me I'm on the right track.

    It's also funny that the tutorials about families that are around in the site are AWFUL. With no bad intention I can say 2/3 tutorials I've read were wrote by people that didn't actually fully understand their craft.

    I'll download and check your demos shortly to see if there's more I can improve.

    Now it's lunch time.

    Cheers

  • Welp. Thanks. I was using a quite old version without knowing it and had to update to open your projects.

    dropbox.com/s/lbewjvv6rekd2na/IsometricForest.capx

    I see that in line 4 you avoid having to waste a variable for sorting the Z order of the family with that "For each" event. I've used the "Sort Z order" action that demands to input a variable to use for checking. Nice!

    But why have you added an extra condition-empty event in Line 3 with a "Wait 0 secs" command?

    Looks like a weird workaround for something. I must know.

    dropbox.com/s/6num28c6nf9qhfb/ZOrderBuilding.capx

    Haha. Yes. That's the way I did it. But now I know you can do it without adding a variable, i'll go with the first method.

    Thanks again for taking the time to reply. And I hope you'll be here the next time I'm stuck.

    Btw, you've probably noticed by now, but my English is rubbish at times. Sorry for that.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • "Sort Z order" action is actually better for performance. But since I only sort two objects on every tick (not all trees in the forest), I guess my method should also be fine. Anyway, if you have too many objects and notice that z-sorting them is slowing the game down, try "Sort Z order" with a variable.

    "Wait 0" is simply to wait for all trees to be created, before initially sorting them.

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