Help with advanced layering anyone?
Cutscene Entertainment
Member, PRO Posts: 138
Hey, everyone. Just wondering...
Would it be possible to do advanced layering for a legend-of-zelda type of game where things could go infront or behind other objects on the scene based on which was higher? Sorry if I'm not as clear as I could be, but it seems impossible.
For the environment, I just used layers creatively and it worked out. For enemies, I could just say, "if below player, switch to your clone on the layer beneath, and if above player, switch to your clone on the layer above". But still I can't get the enemies to do that relative to each other. And switching to clones on other layers really messes up some complex AI behaviour.
I'm also asking this to the GS team, but any help from you guys would be greatly appreciated.
Answers
You'll want to check out Deep Blue Apps' Zanda template. I believe it's available on GSHelper.com. It does what you're describing although I'm not sure about the enemies aspect.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Thanks, Tatiang. However, I've seen that template and I know how it works there. That method only works efficiently for static objects and it definitely doesn't work with multiple enemies that can move around freely. Honestly I've been trying to figure this issue out for almost half a year and I'm beginning to think it's never going to be possible. Especially not in the offline version of GS. But these forums tend to surprise me.
I haven't been able to come up with any solid solution, however I only worked on a few projects that involved layering.
I had a table. And a master_table that was 2 x 10. Which is used to copy into the first table (Layer).
I only worked with 10 enemies on screen at once. And. only ever used their Y positions to determine layering.
Every 0.5 seconds, would copy the Master table into the Layer_Table.
Each enemy had an ID. from 1 - 10. Starting at the enemy at ID 1, it would add its Y position to first row.
Then the the following enemies, continuing with 2, use the loop behaviour and check each row to see which number it is greater than. Then create a row at INDEX related to the empty spot. Always starting with 1. So if the top row was greater than its Y position, it wold look at row 2. If row 2 was zero, than this enemy would change that row to it's Own Y position.
In the second column, I would record that Enemies ID.
This happened until all 10 enemies were listed in the row according to their Y position.
Part 2:
For each enemy, I had 10 different layers. Each with their own Layer ID. Basically, you place each enemy down. Then repeat for 10 times so you have an enemy that will be on top for each position its at.
Then, the enemy with the Layer ID equal to its row ID will be the one to displayed.
Not sure if that makes since. There is an actor of the 10 enemies all given the Layer ID 1. So if their Enemy ID is in the first row, we know it has to be on the top. So no other enemy with the layer ID of 1 will be allowed to be shown.
Not sure how well that will scale with a larger amount of Enemies.
Best,
Two.E
GSLearn.com | Templates | Free Demos | Udemy Course
That's an interesting solution- but how does it automatically hide the ones you don't want to see? Do you have some kind of alpha attribute coming into play somewhere that I missed?
A change alpha to 0 In the otherwise section of the rule that looks to see if they need to be displayed.
GSLearn.com | Templates | Free Demos | Udemy Course
Interesting. I need to do some research on loops and INDEX and then I'll see if I can figure that out. I'd be willing to limit the amount of enemies onscreen if it means that I can actually get them to have orthographic depth. That will open a whole world of possibilities. Thank you for the help.
@Cutscene Entertainment I wondered this years ago and the peoples answered with this: https://forums.gamesalad.com/discussion/86248/controlling-actor-layers#latest
You may have too many objects for these systems to work though.