I'm busy with my full blown project in unity, it's a 2D game as I thought this would make a good starting point.

So to the problem, I've got 3 elements in the game. The ground, an object and a beam. The ground is set to layer 2 and the object to 3. This gives the effect that the object is on top of the group which I need. Now the beam is what I'm having the problem with. I need the beam to be ontop of the object so on layer 4 for example, but I also need it to be behind the ground so layer 0 or 1.

If anyone can point me in the direction that may help or give me any tips i'd be grateful.

Screen shot

As requested I uploaded a screenshot.

So here the object(the cow) is on top of the ground layer. The beam is ontop of the object but it's also ontop of the group, I need it to be beneath the ground.

  • \$\begingroup\$ Can you show us an image or mock-up of what the result should look like? Ordinary layer ordering can't do this type of non-transitive layering, but we may be able to propose alternatives that accomplish the visual end goal. \$\endgroup\$ – DMGregory Aug 16 '18 at 17:21
  • \$\begingroup\$ @DMGregory Added a screenshot with description \$\endgroup\$ – Demonic218 Aug 16 '18 at 17:33
  • \$\begingroup\$ You can place the beam on the top layer and use the ground as a mask for the beam, but the result you're asking for seems like it would look very unnatural. \$\endgroup\$ – Kyy13 Aug 16 '18 at 17:46
  • \$\begingroup\$ @Kyy13 - I'll look up creating masks, thank you for the tip. I don't like the way it currently looks and i figured with it behind the ground it might looks like it's hitting the grass and going no further. \$\endgroup\$ – Demonic218 Aug 16 '18 at 17:50
  • \$\begingroup\$ have you tried moving the beam up in y value, so it's in the middle (looks like it's on top) of the grass? \$\endgroup\$ – Kyy13 Aug 16 '18 at 17:52

You could use the ground as a mask for the beam, but I think it will give you an unnatural looking effect.

Another option is to separate the ground sprite into 2 parts with a horizontal slice right through the grass. The beam will be in front of the top half and behind the bottom half. Layer order goes like this.

background > grass_top_half > cow > beam > ground_bottom_half.

You can also make the slice bumpy to follow the curves of the grass.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.