Need Help with Top Down a la Zelda Object Sorting
Hey there,
I am fiddling around with a zelda like rpg. I am having a hard time with the sorting of tall objects like pillars or trees. Imagine that tall pillars are overlapping each others. I have some very basic events that goes something like : if player Y position > than the pillar position then move pillar to front (draw order). But that is obviously a problem when you have two pillars overlapping each others because it moves the one that is supposed to be behind, in front of the pillar that should be in front.
Thank you for your help !
Re: Need Help with Top Down a la Zelda Object Sorting
If I can add these important details. I will be layering tons of those objects in the game in order to create breakable walls.Since the game has a perspective (not completely top down) the player can be in front r behind those objects.
Thanks you !
Re: Need Help with Top Down a la Zelda Object Sorting
I made you an example, it uses the Layer object that come with MMF (I think...)
http://www.rhysd.com/layeringobjectsa.mfa
Re: Need Help with Top Down a la Zelda Object Sorting
I'm assuming you want it so that when the player moves behind the tree, the player is underneath the treetop so it appears he is behind the tree? All you need is two layers. On the top layer have the objects that the player is supposed to be under (treetop, top of pillar, etc), then on the same layer with the player have the tree trunk that the player collides with. If this is what you are wanting, you don't even need to use the layer object to sort anything.
If that doesn't make sense I'll make an example for you.
Re: Need Help with Top Down a la Zelda Object Sorting
You're referring to Z-sorting, and the layer object is probably the best method for this (as posted above)
Sure you could try Shawn's method, but if the player is able to walk behind a lot of stuff, that's going to be tedious cutting everything up into separate objects.
For Zelda: A Link to the Past, they merely had several layers in their tileset and did much like Shawn suggested... The problem here is that MMF isn't very tileset friendly... Meaning you'd have to move around a lot of active objects to get the same effect.
So yeah, I'd say go with the layer object... That will let you keep each object down to one active. Though I think I've tried it out before and sometimes you'll still get weird issues with objects swapping z positions.
Re: Need Help with Top Down a la Zelda Object Sorting
Quote:
Originally Posted by Konidias
That will let you keep each object down to one active
I'm curious though how you'd handle the collision with only one active representing the tree if you are going for an overlap effect? Somehow, you'd have to only collide with the trunk while moving the treetop forward. With one object you'd either have to collide with the entire object itself or not at all. MMF2 doesn't allow you to define your own collision masks for actives. Which raises another issue... you'd be using a lot of actives for no reason. Making the background as actives when you could easily just use backdrops on separate layers is not very efficient. Actives take more resources than backdrops. Also using the layer object for this is a lot of unnecessary events.
Unless I'm misunderstanding what you are saying, there is no way to get the desired effect with one active for the entire tree or pillar.
Re: Need Help with Top Down a la Zelda Object Sorting
Putting the collision box inside the animation for the obstacle would work.
Re: Need Help with Top Down a la Zelda Object Sorting
Quote:
Originally Posted by Konidias
Putting the collision box inside the animation for the obstacle would work.
I don't understand what you mean? You can't put a collision box in the animation. The collision is the entire graphic, which goes back to what I said about not defining your own collision mask. In order to have a collision box, you'd have to use an invisible active on top of the tree graphic and have the tree set to not be an obstacle. In which case, you'd be far better off just using backdrops on layers.
Re: Need Help with Top Down a la Zelda Object Sorting
Say you have a 32x64 tree, but you only want to have the bottom 32x32 pixels be an obstacle... Well you'd just have the tree graphic in the Stop animation and then you'd put your 32x32 box in another animation inside the active... then you'd just switch the animation to the box before doing collision checks, after the collision checks in your event list, you'd switch it back to the Stop animation.
So the end result would block the player but you'd only ever see the tree graphic, and not the box, since it's not displaying at the end of the game loop, only during the collision check.
Re: Need Help with Top Down a la Zelda Object Sorting
Wouldn't that produce a flashing effect though? You'd have one animation as the whole tree, and one with only the trunk. Switching between those would make the tree flash or blink, I would think.
At any rate, I made a quick example for him showing my method.
http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Number=218065#Post2180 65
Granted, using multiple objects as opposed to one would take more time, but if switching animations causes it to flash, I'd just use backdrops.