Seeing Through Tree Cover

This forum is currently in read-only mode.
0 favourites
From the Asset Store
********** 2D top down animated saw trap **********
  • I'm playing around with hand-painted environments for an RPG, and have got a lot of trees ready to map with. The trouble is, if you're standing behind a tree, you obviously can't see your character, or any enemies he may be in combat with. If you're in woodland or forest... it's going to be impossible to play.

    So would it be possible to make an invisible circle around your character that erases parts of the trees it comes into contact with? Giving the effect of seeing into the section of woodland your character is standing in, without just erasing all the trees completely?

    Hard to explain so here's a visual example I've mocked-up:

    Default tree: http://i216.photobucket.com/albums/cc212/darkstorne/canopyeraseexperiment.jpg

    Tree with erasing effect: http://i216.photobucket.com/albums/cc212/darkstorne/canopyeraseexperiment2.jpg

  • You may be able to get your desired effect with the canvas object, but I'm not sure about that.

    What I do in this situation, is make the particular object obscuring my character go slightly transparent while he is behind it.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • So would it be possible to make an invisible circle around your character that erases parts of the trees it comes into contact with? Giving the effect of seeing into the section of woodland your character is standing in, without just erasing all the trees completely?

    Hard to explain so here's a visual example I've mocked-up:

    Default tree: http://i216.photobucket.com/albums/cc21 ... riment.jpg

    Tree with erasing effect: http://i216.photobucket.com/albums/cc21 ... iment2.jpg

    There is an actual ERASE effect, which you could try to use to achieve something likes this. Just slap it on a circular sprite and activate it if the according conditions are met. Well, and I believe you should activate the FORCE OWN TEXTURE attribute of that layer. Don't shoot me if that's wrong though...

    Other than that, there's also the OUTLINE effect. Which was pretty common to use that way in older games. It's maybe not what you would want.

    That's a pretty tree btw.

  • You could also have a fullscreen canvas, paste the trees that are in front, then paste a circle sprite with the erase effect to it.

  • maybe if the tree is overlaping the player,set tree opacity to 20.

  • In most games, don't they change the entire tree's opacity? Try it out like that (it shouldn't be hard) and see what you think. If it looks good, you won't have to mess with anything very complicated.

  • Thanks for all the advice! I'll definitely use transparency instead of a complete invisibility, so I'll see if I can get that working with the canvas. If not, I will just have to turn the whole tree transparent instead, which still does the job.

    Thanks again.

  • Thanks for all the advice! I'll definitely use transparency instead of a complete invisibility, so I'll see if I can get that working with the canvas. If not, I will just have to turn the whole tree transparent instead, which still does the job.

    Thanks again.

    Just to clarify what I was getting at in my earlier post... here's a simple example:

    http://dl.dropbox.com/u/2306601/treesee.cap

  • > Thanks for all the advice! I'll definitely use transparency instead of a complete invisibility, so I'll see if I can get that working with the canvas. If not, I will just have to turn the whole tree transparent instead, which still does the job.

    >

    > Thanks again.

    >

    Just to clarify what I was getting at in my earlier post... here's a simple example:

    http://dl.dropbox.com/u/2306601/treesee.cap

    Wow, thanks for taking the time to put that together! For some reason I'm struggling to get this to work when I edit the tree's layer mask though... I want the tree base to be solid so that the player cannot walk through the trunk, but is still able to walk behind it. So I've made the tree a solid object and erased everything from the layer mask except for the base. The collision detection works, but the player doesn't disappear when he walks behind it and the circle doesn't show up.

    If I remove the 'solid' attribute from the tree then the player disappears behind the parts of the tree with the layer mask, appears correctly in front on the tree, but still shows up on a higher layer when he should be behind it whenever he's not in contact with part of the layer mask. And, of course, he can walk straight through the trunk...

    I guess I'm doing something very wrong here? Should layer masks for trees not be deleted at all to achieve this affect? And if so, how can I make the trunk a solid object? Using an invisible block at the base could help I imagine, but would lose the exact pixel collision.

    Hope that's not too confusing :S

  • Wow, thanks for taking the time to put that together! For some reason I'm struggling to get this to work when I edit the tree's layer mask though... I want the tree base to be solid so that the player cannot walk through the trunk, but is still able to walk behind it. So I've made the tree a solid object and erased everything from the layer mask except for the base. The collision detection works, but the player doesn't disappear when he walks behind it and the circle doesn't show up.

    Well, that's not really surprising since the events in my example use an overlap condition in order to work. And when you edit the collision mark, it doesn't overlap anymore properly.

    If I remove the 'solid' attribute from the tree then the player disappears behind the parts of the tree with the layer mask, appears correctly in front on the tree, but still shows up on a higher layer when he should be behind it whenever he's not in contact with part of the layer mask. And, of course, he can walk straight through the trunk...

    I guess I'm doing something very wrong here? Should layer masks for trees not be deleted at all to achieve this affect? And if so, how can I make the trunk a solid object? Using an invisible block at the base could help I imagine, but would lose the exact pixel collision.

    Hope that's not too confusing :S

    A little confusing right there, hehe. I'd say you should put another sprite in a container with the tree. That object would be invisible and be solid. You shape it accordingly and set it to the tree's position with an event. That should take care of that.

    But another problem I would see with this method is Z odering. Like smaller stuff, that would be behind the tree (like a flower for example), but maybe in front of the player at his feet and visible too, when the player is covered by the tree. I guess that may have sounded a little confusing now as well. Anyway, at this point I'm not quite sure how I would achieve this myself, while still using the basic method I showed. Maybe I'll give it another try these days.

  • Here's my take on this.

    I used PixelRebirth's CAP as a base, so I took his sprites!

    http://dl.dropbox.com/u/7324985/treesee2.cap

    Basically it tests for distances, then set the opacity of a tree to less-than-100 if the distance between those and the player are below X. Then, using the value of this distance, we can add a soft easing on the distance when the player moves.

    The tradeoffs for this example over what you were discussing are:

    +) Using the Y as reference for what's behind or in front of the player (Z ordering), you get more control of which tree to apply the effect.

    o) The whole tree disappears (or nearly disappears - you just tweak the lower value). I don't know if its positive or not, but personally I like this style.

    -) CPU intense: You may have to come up with better events if you use hundreds of trees on a level, the way I did it tests every tree in the level in every tick - not a nice idea.

  • I used PixelRebirth's CAP as a base, so I took his sprites!

    How dare you steal my block tree and stickman sprites? That was hard work dude!

    Basically it tests for distances, then set the opacity of a tree to less-than-100 if the distance between those and the player are below X. Then, using the value of this distance, we can add a soft easing on the distance when the player moves.

    The tradeoffs for this example over what you were discussing are:

    +) Using the Y as reference for what's behind or in front of the player (Z ordering), you get more control of which tree to apply the effect.

    o) The whole tree disappears (or nearly disappears - you just tweak the lower value). I don't know if its positive or not, but personally I like this style.

    -) CPU intense: You may have to come up with better events if you use hundreds of trees on a level, the way I did it tests every tree in the level in every tick - not a nice idea.

    Generally I like your approach. Without checking the Z ordering (like you mentioned) it appears a bit odd when even trees that arent in front of the player get faded. So that should definitely be added.

    Oh, why did you use an always event there? You can just loose it and it works the same, btw.

  • Pixel and Gamma, I love you both.

    I've got the collision with the trees working, sending the player to the front or back as needed with Pixel's advice, and the tree opacity blending looks gorgeous using Gamma's method.

    Can you explain the numbers used in the events a bit for me Gamma? Unfortunately, I'm an artist and literature student, so numbers bamboozle me to no end. I've been experimenting with altering them to increase the range at which the erasing effect begins (since my tree models are pretty huge), but haven't had any luck yet :S I think it would help if I had an idea what the numbers did.

    Many thanks for the assistance.

  • Generally I like your approach. Without checking the Z ordering (like you mentioned) it appears a bit odd when even trees that arent in front of the player get faded. So that should definitely be added.

    Oh, why did you use an always event there? You can just loose it and it works the same, btw.

    I imagine getting rid of the 'always' event would help performance too? I'll see if I can work out how to check for z ordering with this method.

  • I imagine getting rid of the 'always' event would help performance too?

    It's not really a performance hit, just unnecessary. The loop will run every tick with or without that always event.

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