Thoughts on pseudo Depth.

0 favourites
  • 9 posts
From the Asset Store
A very simple to set up ZElevation based depth of field system for your game. Fully commented.
  • Rather than just lazily ask for an answer , I'm currently experimenting with creating pseudo depth to a scene and was wondering if anyone else wants to know the same and explore a solution with me.

    Here are the Goals:

    To spawn character sprites in the game and then based on their hight in the view ( or screen ) The smaller or larger the scale, but also they need to be placed behind (Z Order?) the lower and so larger characters, this will create the illusion that the smaller characters in the view are behind and further away than the larger characters in the scene.

    The Solution: Some how I'm thinking maybe track the characters Y position and preform some maths on the characters overall size based off that, so the higher in the frame the smaller it gets, and then some how preform a test that checks each characters y position on spawn and sets its Z Order accordingly. Not sure if you can number the Z Order though so may need to look for a different solution to that problem.

    This seem like a good way to go?

    Regards

    Joel

  • For a single object of instances you can check each using a loop, and comparing its y to the loopindex.

    If they meet the criteria, send that one to the front.

    Or you can just do a "for each object" (ordered) by y ascending, send to front.

  • For a single object of instances you can check each using a loop, and comparing its y to the loopindex.

    If they meet the criteria, send that one to the front.

    Or you can just do a "for each object" (ordered) by y ascending, send to front.

    Yes I thought that might work, but sending to the front would only work for 2 objects or if the objects were spawned in a sequence, what if you had lets say 3 characters and wanted them to sit in order? As far as I have seen there is no way to specify that Character 2 who's Y position is between 1 and 3 be placed in between them in terms of Z Order ( So in front of character 3 but behind character 1 ). Or would your solution account for that? Maybe I'm just missing something obvious? :S

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I think you're missing something a little obvious- if I put Character 3 on top, then 2 on top, then 1 on top, what order are the characters in?

  • I think you're missing something a little obvious- if I put Character 3 on top, then 2 on top, then 1 on top, what order are the characters in?

    I know that but if you have characters randomly spawning in then it does not work, for example if a character in front spawns then a character in the background spawns but I need the one in the background to be behind one but in front of one it is not so easy. Its easy to solve if your characters are a set amount and all spawn in order but if I want to make a random small crowd the method you suggest will not work

  • Actually, the method can work, because you can rerun that loop whenever you need.

    Take a look at this .capx.

    In this case, I'm running the algorithm every tick until I'm done spawning. You could run it exactly once every time you spawn a new character, instead, and the end-user would never see it.

  • Keep in mind its a loop, and will eat up cpu.

    Every tick, even for a short period may be a bit much.

  • But if I run it on create, it doesn't seem to 'catch' until the next tick?

  • But if I run it on create, it doesn't seem to 'catch' until the next tick?

    Ahh I see what you mean now , I forget the Y value could be done by acending, which negates any problems with them being on top of each other. I stand corrected. Yes I suppose then all that would need to be addressed would be the memory issue, maybe spawning them all at once or get it to run 1 loop store it in an array then use the array info to spawn the sprites. Hmm will look into that and let you guys know the results. Thanks so much for helping work through this, appreciate it.

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