Moving in and out of shadow

This forum is currently in read-only mode.
From the Asset Store
This is a code so you can see the same skin on all screens (peers). Each peer gets a skin, in addition to 4 directions t
  • I'm having a fairly unique problem, but I just have no idea how to fix it. I've created a family called 'shadows' and when an object is overlapping one of the objects in this family, it is given a grey colour filter and when it is not overlapping a 'shadow' object it is given a white colour filter (i.e. no colour filter).

    This worked when I had only one object (the player) that was moving in and out of shadows. Now it seems, after I've added some other objects (the rocks) overlapping the shadows, the player object does not lose the grey filter when it leaves the shadows.

    To make things more clear, I've included a .cap file. I realise this is a small problem in the grand scheme of things, but its one I have no idea how to fix.

    .cap download

    The events in question are in the 'terrain events' event sheet.

  • I think it is a bug with else condition, i fixed it using 2 conditions:

    If Terrain overlaps Shadows And Value "Nodarken" == 0 > Set filter to Gray

    (INVERTED)If Terrain overlaps Shadows > Set filter to White

  • Ah, I can't believe I didn't try that. Thanks a million :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • No, there isn't any bug with the else-condition. While it is working correct, the logic behind the creation of the events is incorrect.

    Let's have a closer look at it:

    + Terrain: Terrain overlaps Shadows

    + Terrain: Value 'Nodarken' Equal to 0

    -> Terrain: Set filter to

    + System: Else

    -> Terrain: Set filter to

    On every tick CC is ordered to check if any Terrain overlaps any shadow. Of those, only the ones with the correct value of the pv are picked. This selection of objects get a grey filter.

    But using 'else' here means that only if NO terrain is overlapping any shadow, all terrains will get the white filter.

    As you can see in your layout, there are several instances of 'Whiterock2' that always overlap a shadow object, so the else-branch will never be executed, because the first conditions are always true.

    Currently all terrain objects are tested on every tick. Unless it isn't so, you can (besides Metal_X's solution) also do it just like this:

    + System: Always (every tick)

    -> Terrain: Set filter to white

    + Terrain: Terrain overlaps Shadows

    + Terrain: Value 'Nodarken' Equal to 0

    -> Terrain: Set filter to grey

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