Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by Danteeva · Jan 11, 2014 at 04:23 PM · spritespritessorting layers

Sorting Layers not working?

Hello, I'm currently trying to sort the layers of my sprites so that my player shows on top of my enemy sprites. But no matter what order I put the sorting layers in the enemy always shows on top. I make sure to set them to their layers. I've tried all the layers in every order and nothing changes, apart from if i put the background after the default I can only see the background, even though I cant set it to a sorting layer.

Ive also tried setting them to the same sorting layer and putting them in different orders but still the same results.

I'm stuck at the moment, I've had a look at other questions about it but I'm not sure what they are talking about. Any help would be appreciated.

Comment
Add comment · Show 10
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Danteeva · Jan 13, 2014 at 05:37 PM 0
Share

Can anyone help me, nothing i try changes what order they come up in, the player always goes behind the enemies even though they are on the same point of the Z axis

avatar image dnh452 · Jul 29, 2014 at 08:58 PM 0
Share

I'm having the same issue. When I debug, the settings are sticking, but in the game view, the element is still behind an item with a lesser sort order


public LineRenderer catapultLineFront;


catapultLineFront.SetPosition(0,catapultLineFront.transform.position);


catapultLineFront.sortingLayerName = "Foreground";

catapultLineFront.sortingOrder = 3;


The catapultLineFront object is still showing behind a sprite with an order in layer value of 2.

avatar image jcastaldo13 · Aug 16, 2014 at 06:02 PM 0
Share

Its not working for me either. Why hasnt anybody answered this question?

avatar image Hathakas · Jan 21, 2015 at 12:50 PM 0
Share

Having the same problem here, $$anonymous$$y layers used to work but now It's all jumbled up. It doesn't even matter if I put an object in the background layer (second from the top in the settings) and my foreground layer (bottom of the settings). Any suggestions?

avatar image Chris333 · Jan 21, 2015 at 04:31 PM 0
Share

Hi, is the Camera Projection set to Orthographic?

Show more comments

3 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by smoggach · Jan 21, 2015 at 05:25 PM

Make sure to check the layer and camera depth. Besides sorting order Unity also uses Camera Depth. If the camera rendering your enemy has a higher depth than the camera rendering your player it will show above the player regardless of sorting order.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Hathakas · Jan 22, 2015 at 03:35 AM 0
Share

Thank you for the answer, I think I'm close to fixing it, playing with the camera depth and far/near and it's z position is playing a part in all this weirdness :D

avatar image
1

Answer by alex.almeida · Sep 15, 2015 at 01:03 AM

I had the same problem. In my case the issue was that I didn't have a sprite renderer on the objects I was trying to sort. After adding the sprite renderer I used the field "Sorting Layer" on it. Before I was trying to use the field "Layer" in the top of the Inspector.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image augivision · Apr 06, 2018 at 12:21 AM 0
Share

This helped me fix my issue. Thank you.

I added Sorting Layers. Changed the items accordingly and also changed their Order in Layer.

Things I wanted to be on top had a higher Order in Layer than items in the back.

avatar image
1

Answer by rahuljain1311 · Jun 03, 2016 at 05:59 PM

The steps which I took are -

  1. Open Camera in Inspector and set Projection to Orthographic

  2. select your Enemy sprite in Hierarchy and open it in Projection

  3. Open Sprite Renderer component(if not there add it by modifying sprite of enemy)......Click on Sorting Layer and select "Add Sorting Layer"

  4. Now name the new sorting layer "EnemyLayer"

  5. repeat step 3... just this time select the EnemyLayer instead of adding a sorting layer

  6. Repeat steps 2-6 for player sprite also (name the sorting layer as PlayerLayer)

N.B.: Because you added PlayerLayer after the EnemyLayer, player will show above enemy!! you could add as many layer... just order them correctly!

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

28 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Render sprite only on top of a specific sorting layer 1 Answer

Sprite texture size and padded size 1 Answer

Shader vs Sprites - Sorting layer (ZWrite Off not working) 1 Answer

How to merge Sorting Layers ? 1 Answer

Transparency Sort Axis on Y with Pivot instead of Center of object? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges