How do I make objects don't interact with each other on different layers?

0 favourites
  • 9 posts
From the Asset Store
Adjusting the game screen for different resolutions (Letterbox scale)
  • I have it set up so that When the player wins (gets to the goal), the new layer is loaded up and all of the objects that I want go to the layer, but when go to a new layer the objects still interact with other object (like wall/solid objects)

    How do make it so that the player does interact any objects on (lets say) layer 2, but not objects on layer 3?

    Tagged:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • -You can disable collisions on the objects that are on the other layer

    or

    -You can create collisions filters and activate them just when the player wins

  • I asked a similar question about this as my understanding of this game engine is that when you program a layer to become "invisible", the objects that are clickable should also be "invisible". However frequent testing shows that this isn't the case.

    I really believe this is a bug as it is unwanted/unexpected behavior from the game engine. Somewhere there has to be coding in the game engine that needs to be updated to truly mark the layer as "invisible" including all objects on that layer.

    Just my .02

  • -You can disable collisions on the objects that are on the other layer

    or

    -You can create collisions filters and activate them just when the player wins

    Very good work-around (and I honestly used it in my game) however we shouldn't need more coding to make our game work.

  • Invisible means not visible. It does not mean not interactable.

  • Invisible means not visible. It does not mean not interactable.

    Cool. So is there a way to make a layer "not interactable" or do you need to program in lots of collision filters? Not sure why someone would want a layer to be invisible but all of the objects are still interactable.

  • Well firstly in this situation where levels are involved, I would use a separate layout instead, or at least destroy the old level upon transitioning to the new. If I needed to preserve the level to revisit later, I would definitely use a separate layout.

    If in the case of a menu and clicking, I usually have the "layer is visible" condition in the menu events.

    I can't think of much for the layer off the top of my head, but I can definitely say there are a billion and one uses for invisible helper sprites, and I definitely want those interactable. I don't see why layer visibility should behave different than object visibility. The question is why make an entire layer invisible to begin with? I'd imagine maybe for inventory or menus and other interface elements, but again a single condition on the input event solves that. Usually doesn't involve solids.

    The main use case for having solids on layers that become visible and invisible would be maybe something like floors in a building. IIRC this is one of the big issues the collision filtering and tag feature was developed to address, besides stuff like half height objects that block movement but not visibility/bullets ect.

    You don't even need to manually enter a lot of collision tags for solids - just use a loop on start of layout to set the tag to the layer name the object is on. When the player changes layers, set their solid collision filter to the layer they are on, so they can only interact with things on that layer.

    Also, the solid behavior can be enabled or disabled. If you're already changing layer visibility, you can enable solids on the new layer and disable on the old just as easily. There are many ways to deal with this.

    One use case I just thought of for hiding a layer and still have solid interactions is if you wanted a certain set of information hidden from the player, say they got blinded, or hidden enemies. They still need to pathfind, bullets still need to hit walls, ect. even when they are not visible.

    Anyways sorry that was a bit long and rambly, so TLDR back to "So is there a way to make a layer 'not interactable'?". There are a few options, as usual, depending on what the situation requires.

    A. Use the "Layer is visible" condition

    B. Use collision filters. Doesn't necessarily mean a lot of work, and it was designed for stuff like this.

    C. Disable solids on the layer that isn't in use.

    D. Don't use a layer like this to begin with (ie. destroy and create objects as needed instead of just making them invisible), or move to a different layout instead.

  • Well firstly in this situation where levels are involved, I would use a separate layout instead, or at least destroy the old level upon transitioning to the new. If I needed to preserve the level to revisit later, I would definitely use a separate layout.

    If in the case of a menu and clicking, I usually have the "layer is visible" condition in the menu events.

    ..........

    D. Don't use a layer like this to begin with (ie. destroy and create objects as needed instead of just making them invisible), or move to a different layout instead.

    First I have to say, thank you for being incredibly level-headed, taking the time to offer an explanation we could understand and doing so without flexing your vast knowledge. You’re a rare blend and earned my respect (and that of others I’m sure).

    Second, when it comes to layers needing to be invisible and/or using tags for multiple layers so objects aren’t clickable versus using a new layout, this is where I’m so confused.

    I’m using one layout because in the game, I have objects “growing” (crops with a global variable increased in number until it reaches 100 which means it’s ready for harvest). If I use a second layout, those crops stop growing and are reset when you get back to the layout they’re on. I don’t know how to keep them growing when layout is switched so I just use different layers to display alerts, options and menus.

    I really did appreciate your reply and the length provided a lot of information I could follow. Plus, you did it without being condescending! Thanks for the information and I’m hoping you’re willing to offer some insight to using multiple layouts while allowing certain objects to continue to increase in value.

    I’d love to use different layouts so that I used invisible layers properly. Heck I’d even use the tagging method you mentioned if I had some guidance.

    You provided some great options/solutions and if you’re willing to show how (or throw some links out to those guides that could help us), you’ll further your legendary status.

    Thank you again for your time and insight.

  • OK so the situation is different than OP's use, which was changing levels or progressing stages. Crops continuing to grow while hidden.

    There are a few approaches you can try.

    If I had to label one "proper" way, it would still be to use a separate layout. This is assuming you're talking about moving around, to another area or inside a building or something. You would keep track of the time that passed (there are, as usual, few ways to do this), or save the time you left the layout via a global variable. When you go back to the layout with your crops, you would compare the current time with the time you left to get the time that passed, and reconcile that with anything that needs to keep track of time on start of layout. Basically keep track of and just add the time that passed to anything that has a timer, or your global timer.

    Or, you can simply teleport your character to another x/y location on the same layout, representing a building or a different area of the map. Then you wouldn't have to layer things on top of each other at all.

    If you're talking about menus and dialogues, then you probably have issues with clicking and not solids for movement (you don't move around when there's a menu open right?). This would be solved, like I mentioned before, adding a "layer is visible" condition to your clicking events for the main layer and menu layers. For clicking crops, add a "Menu layer is not visible" condition, and for clicking menu items, add "Menu layer is visible".

    Either way, collision tagging is probably not suitable for your situation.

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