Aligning actors in layers for a pseudo-3d environment

dunkelgeistdunkelgeist Member Posts: 68
edited November -1 in Working with GS (Mac)
Hi again!

I have another question for the great minds that surround us!

I'm setting up a scene like this:
https://docs.google.com/leaf?id=0B-pHlLMaonDjZmM0ZTBlZWItODJmZC00ZmQ1LWI0ZTMtMWM0NGE2M2MyZDVj&hl=es&authkey=COHcmtgE

BUT! and it's a big BUT... I can't get the actors to align as I like, if you see the precious drawing, I would like to set actors front or back of each other depending of their Y position, so the higher they are on screen, they have to be at back of others.

In the image, ordered from front to back it should be like this: III - II - I

It's driving me crazy... any suggestions?

Thanks!

Comments

  • simo103simo103 Member, PRO Posts: 1,331
    not sure but I believe there is a complicated solution that involves spawning and destroying into different layers depending on where the actor is so as one actor moves from behind another it then is spawned into a layer that is in front of that actor and the old 'behind' actor is destroyed.

    Don't know if that gives you something to work with. I know Darren has a video of that working in his template pack.
  • dunkelgeistdunkelgeist Member Posts: 68
    Doh! I've seen it now but it's the only thing I'm interested of the mega-pack... so expensive for an only example...

    Maybe Darren could explain it in a few words to make it work by my own hands, that's a 'Pleaaaaaseeeeee' xD

    I don't even know if his template could be useful for me as my actors are moving constantly.

    Thinking of what you said, maybe I can add a layer for, let's say every 10 pixels to make it look a little realistic but that will involve so many rules...

    Also I'm still able to change the gameplay and make it full top-down but that's not so cool with the game mechanics I've worked on.

    Still thinking...
  • AjBlueAjBlue Member Posts: 215
    you could try to put your objects on screen and make duplicates offscreen that are on a higher layer than everything else. then for each object, make it say if main actor is > self.position.y //constrain dup object x to main object x. same for y. otherwise constrain to original position.

    i think that will work, but i haven't tried it
  • dunkelgeistdunkelgeist Member Posts: 68
    @AjBlue
    That's a nice idea... Not sure how to fully implement it but I'll try after work.
    Thanks!
  • dunkelgeistdunkelgeist Member Posts: 68
    I've sweated it a lot but still nothing.

    The thing is I can have an undefined number of actors moving around, up to 5 or so...

    If it was only for one actor i've found it relatively easy to spawn and destroy on different layers but here there's much more movement.
  • msonesmsones Inactive, Chef Emeritus Posts: 75
    Dunkelgeist,

    I spent some time on this issue this afternoon, and will add a new wiki page to show details. One way to do this that doesn't involve ANY spawning or destroying is this:

    Create a second, identical actor. Place one on a higher layer, one on a lower layer. Create a game-level real attribute for each of your actors, and constrain it to the Y-value (position) of that actor.

    Now, as you move your actors around, have a rule that checks whether the Y value is lesser or greater than the actor you want to move in front of or behind of. Have your identical actor exactly match the movements of your main actor. If the Y value is less, change the alpha value of the one actor to 0 and the other to 1; if the Y value is more do the opposite.

    Basically, you'll have one actor visible above certain points, and the other visible below certain points.

    This may not be the best way to do it for your project, but it's one possible way of handling things that doesn't require any spawning or destroying. Here's the wiki article:
    http://gamesalad.com/wiki/how_tos:multilayermovement
  • dunkelgeistdunkelgeist Member Posts: 68
    Mind-blowing... I really appreciate that! Thank you soooo much!

    It really isn't perfect for my game as it is but it's easily adaptable.

    That, a little actor detecting collision just at feet size and an interpolation of size as the characters get far from bottom will make it soooo cool!

    Thanks again!!! Now I've got a lot of work to do :D
  • quantumsheepquantumsheep Member Posts: 8,188
    @Msones

    My mate Jake and I were discussing this just today! Crazy, eh? :)

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

Sign In or Register to comment.