playMaker

Author Topic: Screen Pick 2D vs. Sprite Renderer - Order in Layer  (Read 3806 times)

purbanics

  • Junior Playmaker
  • **
  • Posts: 55
Screen Pick 2D vs. Sprite Renderer - Order in Layer
« on: April 01, 2014, 05:58:50 AM »
Hi,

I am using Screen Pick 2D action to grab and then move sprites around in Unity2D which sprites are all at same Z depth and at same sorting layer but every time I touch a particular sprite I increment it's Order in Layer so it will appear above all other sprites after that touch.
This works fine.

The problem is that the Screen Pick 2D seams to not take this Order in Layer into account and when there are multiple sprites above each other it seems to randomly select one of them.
I expected that it would select the one on the top every time.

Is this a bug of the Screen Pick 2D that it does not take the Order in Layer into account?
Or is this as designed that it only use the Z depth?

Please explain. Thanks,
Peter

purbanics

  • Junior Playmaker
  • **
  • Posts: 55
Re: Screen Pick 2D vs. Sprite Renderer - Order in Layer
« Reply #1 on: April 07, 2014, 06:11:30 AM »
Please give me some info about this.

Thanks in advance,
Peter

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Screen Pick 2D vs. Sprite Renderer - Order in Layer
« Reply #2 on: April 07, 2014, 07:49:36 AM »
Hi,

 I can't find in the Unity doc a method do this. This action uses Physics2D.GetRayIntersection method, and it doesn't mention ordering layer.

 so typically, I am not even sure how this case would be achieved with scripting. There is very few info when I google for it, so I would for now make use of the z depth for an efficient way out of this and not rely on the sorting order for raycasting.

bye,

 Jean

purbanics

  • Junior Playmaker
  • **
  • Posts: 55
Re: Screen Pick 2D vs. Sprite Renderer - Order in Layer
« Reply #3 on: April 07, 2014, 08:35:57 AM »
That's pretty disappointing that the Physics2D.GetRayIntersection does not take the ordering layer into account.

So it seams that even when using Unity 2D, you can't forget about the Z depth... yet.

Thanks,
Peter

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Screen Pick 2D vs. Sprite Renderer - Order in Layer
« Reply #4 on: April 07, 2014, 11:24:08 AM »
Hi,

 Indeed. It's bit of a shame really, I agree on this. I think it's possible, only that's it's not efficient and therefore not really something to spread out in the wild withotu caution. Relying on the z depth will definitly perform as expected, so I think it's best to stick with it, and maybe contact Unity to push them. They really take feedback seriously, so the more they know about what's expected, the better.


Bye

 Jean

purbanics

  • Junior Playmaker
  • **
  • Posts: 55
Re: Screen Pick 2D vs. Sprite Renderer - Order in Layer
« Reply #5 on: April 08, 2014, 02:01:40 AM »
I asked in the Unity forum.
I'll post here when there is any new information about this.

Br,
Peter