simulating depth in a 2D enviroment
Hi everyone...
I want to simulated depth in my 2D enviroment, by having the player move behind objects (or in front of). I was thinking about using the Y coordinate to calculate depth, you know? It would works something like this:
If player.Y < obstacle1.Y then put player behind object1...
The problem is, that I will have a lot of objects in my scene and I wanted to know if you know of a better way to do this... 'cause otherwise I will end up having a lot of conditions... you know?
I tried using qualifiers, giving the objects the "neutral" qulifier, and then asking:
- Is player.Y < Neutral.Y then put player behin Neutral...
But this results in the player being behind every single "Nuetral" object.... which is not what I want...
Can somebody give me a hand with this?
Thanks in advance!
- Haora
Re: simulating depth in a 2D enviroment
What kind of game are you making? If it's a platformer, I might be able to help. There's a tutorial on Sonic Fan Games HQ about parallax that may be helpful. Just go to the Tutorials link on the left, and click on the section called Special Effects and click on the Paralax tutorial (they spelled it wrong, but you'll still recognize it ;) ). This helps make objects appear both behind, and in front of, the player (with parallax!). :)
Re: simulating depth in a 2D enviroment
What the King's Quest games did (sort of side-on-ish view) was to have various "bands" that objects could be in, from the front to the back of the screen. This isn't so different from what you're doing now, but it's a matter of getting it to work with groups correctly.
I think the Layer object has an "Order by..." condition - you could use the Y co-ordinate of your group with that and see if that helps.
Re: simulating depth in a 2D enviroment
Thank you Neonotso and DavidN....
But it's not a plataformer, it's a graphic adventure...
What I'm trying to do, it's more like what David said... but I just don't see how to make those bands he's talking about....
And FYI, that "Order by..." condition, only sets the initian order of the objets, if you choose "order by y-coordinate" it won't make a difference if later in-game, that coordinate changes....
Anyone else? I would really like to do this without having 2 conditions for every single object I want to pass behind and in front of...
Thanks in advance!!!
Re: simulating depth in a 2D enviroment
From what I read, It could be like arcade fighting games as Final Fight, Double Dragon and Golden Axe.
Characters moved left and right, but they could also move closer or away from the screen.
If it's the case, then it's just a matter of moving up or down in Y. It's the visual environment that makes it look like the characters are moving close or away.
Re: simulating depth in a 2D enviroment
Yes, but I need the main character to move behind and in front of different objects...
THAT's what I'm asking here... how can I, based on the Y coordinate of said character, make it be behind or in front of an object...
And don't say, "well, check for the coordinates of every object and if the main cha is higher then move it behind the object", 'cause I'm already doing that...
I'm looking for a more generic way to do it, in case I have too many objects in my scene...
Thanks
Re: simulating depth in a 2D enviroment
Maybe you need to set a condition that the other objects check then if one of the object meets that condition it sends a message to the main character to change position.
Re: simulating depth in a 2D enviroment
Mh, that could be a posibility.. still, there would be at least one condition per object... is there a way to group the objects and then have like 1 or 2 conditions total?
Thanks for all the help!
Re: simulating depth in a 2D enviroment
Layer Object.
Then give your objects to layer this code:
Always: set Alterable Value L to Y Position.
Layer Object-
Always: sort by Alterable Value L, decreasing
First line could be modified for special cases where you need them to offset a bit. Like this:
Flag off: set Alterable Value L to Y Position
Flag on: set Alterable Value L to Y Position minus 48
And then your event to set Flag on or off.
Re: simulating depth in a 2D enviroment
YES!, that was IT!
Thanks so much, now I just need to get the offset right, and I'm good to go... thanks again! :D
- Haora
Re: simulating depth in a 2D enviroment