The Daily Click ::. Forums ::. Klik Coding Help ::. Easy object ordering in top-down isometric game.
 

Post Reply  Post Oekaki 
 

Posted By Message

Jake G



Registered
  06/03/2010
Points
  782

Wii OwnerVIP Member
31st October, 2013 at 31/10/2013 07:45:24 -

Heya,

I'm making a game in a top-down perspective (like A Link to the Past for example). And want to know if there is a simple way to code objects to dynamically layer themselves according to whether they are in-front or behind the player.

Currently I've said:
>>If Y("Player") > Y("Rock") then Order "Rock" behind "Player" and
>>If Y("Player") < Y("Rock") then Order "Rock" in front of "Player".

This works flawlessly... if there is only 1 instance of the Rock object in the level (and I think it works too if the height of the rocks aren't in the same Y-Zone of any of the other rocks in the scene).

The problem is, if these Y-Zone conditions aren't met, the code will work fine with ONE of the rocks, but not for any of the others (in the case of the screenshot below it works with the left-most rock).

Image

Does anyone know a way around this? Much appreciated.

Sorry about the on-screen keyboard in the screenshot - my iMac keyboard doesn't have a key to print screen with.

Edited by Jake G

 
Visit www.voltic.com.au - you probably won't regret it!

~Gradually getting less bad at making games~

Jake G



Registered
  06/03/2010
Points
  782

Wii OwnerVIP Member
31st October, 2013 at 31/10/2013 09:03:43 -

Found a simple solution - add "+ "Player" is overlapping "Rock" to the event and it changes to being object-specific! But still if anyone has any other methods I'd love to hear them.

 
Visit www.voltic.com.au - you probably won't regret it!

~Gradually getting less bad at making games~

s-m-r

Slow-Motion Riot

Registered
  04/06/2006
Points
  1078

Candle
31st October, 2013 at 31/10/2013 13:21:32 -

Yup, you solved it the way I would have suggested. The only thing I'd double-check is which object you should check first. Such as...

IF Player Object is overlapping Rock

- or -

IF Rock is overlapping Player Object

Be sure to do some playtesting to figure out if your event structure will impact how things turn out.

It's kind of a nit-picky thing for sure, but we all hear so much about Event and Condition order and all that. Just keep your eyes open for it.

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
31st October, 2013 at 31/10/2013 14:02:58 -

The layer object has an option to sort objects by their Y position (just be careful with hotspot positioning)

 
n/a

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49667

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
31st October, 2013 at 31/10/2013 20:55:27 -

Yeah the layer object works well for this sort of thing, but if you want to avoid extra extensions then the method you described works well too.

 
n/a

Riptide



Registered
  26/07/2013 21:07:20
Points
  101
31st October, 2013 at 31/10/2013 22:12:19 -

Hi
Can't you just do something like

• Y bottom point of Player < Y bottom point of Rock
=> Player: Move behind rock

• Y bottom point of Player > Y bottom point of Rock
=> Player: Move at front of rock

?????

Edited by Riptide

 
Working on some engines, working for the fun !

Jake G



Registered
  06/03/2010
Points
  782

Wii OwnerVIP Member
1st November, 2013 at 01/11/2013 01:55:54 -

Good point s-m-r, I've noticed that seemingly the same event (in a different order) can have a different result. I'll have a play around.

Sketchy snd UrbanMonk, I've never used the later object outside of hiding and showing layers, know of any good tutorials on all it's features?

Riptide, yeah that works perfectly but only when you have one instance of the object in question in a scene, having multiple objects in a level (as per my screenshot) causes some issues

 
Visit www.voltic.com.au - you probably won't regret it!

~Gradually getting less bad at making games~

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49667

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
1st November, 2013 at 01/11/2013 22:06:59 -

Do you really need a tutorial for that object Jake? The actions do exactly what they say they do.

 
n/a

Jake G



Registered
  06/03/2010
Points
  782

Wii OwnerVIP Member
2nd November, 2013 at 02/11/2013 00:11:12 -

Ha, probably not. I haven't tried it yet!

 
Visit www.voltic.com.au - you probably won't regret it!

~Gradually getting less bad at making games~
   

Post Reply



 



Advertisement

Worth A Click