Gradual Fade Based on Distance

0 favourites
  • 6 posts
From the Asset Store
Human/Character Base Pixel Art Sprites in various poses (nearly 100 files)
  • Hi everyone,

    I am having some difficulty with getting my player object (a submarine) to trigger the opacity of wall objects. The idea is that the opacity of the walls are initialized to zero so they are not visible until the player begins to move within a certain distance.

    Unfortunately it seems like regardless of the distance I set, the opacity is set randomly. It could be due to there being multiple wall objects placed around the player but I am not sure.

    I have attached a link to the capx but if anyone has any ideas as to how to tackle the problem in general, that would be appreciated too.

    Thanks all!

    Gradual Fade Issue (Updated)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • in your distance expression, you're multiplying wall.y by 0.1.. you'll wanna keep that outside the brackets so it's

    distance()*0.1

    although i think 0.5 might be more what you're after

    also you should save it as a .capx file and upload that, it's the folder contents but zipped up, and can be opened by c2 directly.

  • Doh! Thanks keepee for both the hint on my expression and how to post the capx. I'll give that a shot. :)

  • Hmmm... I still must be doing something wrong. I updated the file in Dropbox if anyone is interested.

    It seems like it is getting confused as to which instance of my wall object to calculate against as it doesn't seem to fire consistently. Sometimes you can run right into a wall and it doesn't fade into view.

  • Problem Solved ...

    Replace your last event by :

    For Each | Wall :

    -- Wall | Set Opacity to 100-(distance(Player.X,Player.Y, Wall.X,Wall.Y)*0.5)

  • Argh! Thanks Whiteclaws! I'll give that a shot as soon as I get home. That would make total sense.

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