Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 /
  • Help Room /
avatar image
5
Question by Tricell · Nov 14, 2015 at 08:49 PM · layers

Sorting layers according to Y axis

Hello - I am new to Unity, and I am trying to make a 2D, top-down, isometrical game. I am wondering how I can sort the layer of objects based on their position of the Y axis using a script. In other words, I am trying to create the effect of a background/foreground according to Y position. For example, if object_1 is beneath object_2, the layer for object_1 should be greater than the layer for object_2.

If anyone can help me, I would greatly appreciate it. Thanks!

Comment
Add comment
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

4 Replies

· Add your reply
  • Sort: 
avatar image
11
Best Answer

Answer by MakinStuffLookGood · Nov 14, 2015 at 09:10 PM

Update for 2020:

Use Transparency Sort Mode on a Camera. You can conveniently set a custom axis project wide to sort based on Y axis instead of Z, mix with Sorting Groups to keep a whole character made of multiple sprites together and sort as a single entity.

alt text


camera-proj-settings.png (30.8 kB)
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
5

Answer by Retruate · Aug 25, 2019 at 09:07 AM

Not to necropost, but since this is the first search result on Google & Bing, if anyone in is here in 2019, there is a much cleaner solution.

Edit > Project Settings > Graphics > Camera Settings > Transparency Sort Mode > Custom Axis ... > Transparency Sort Axis > (0, 1, 0)

alt text


capture.png (24.4 kB)
Comment
Add comment · Show 3 · 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 AlphaBlazer · Jan 31, 2020 at 10:23 PM 0
Share

Is there a way to do this where it sorts by the pivot point ins$$anonymous$$d of the center of the sprite?

avatar image jlreymendez · Mar 15, 2020 at 02:47 PM 0
Share

Thanks for sharing this! This is indeed a much cleaner way of achieving this

avatar image LostRelicGames · May 30, 2020 at 01:51 PM 0
Share

You did well to update this answer, thanks mate.

avatar image
0

Answer by B4ttleCat · Jul 16, 2019 at 02:33 AM

I can't believe how easy it that was to implement. Thank you, @Broxxar, this worked perfectly for me.

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
avatar image
0

Answer by sinedsem · Jan 26 at 03:18 PM

If you are using Universal Render Pipeline you will not see Camera settings in Graphics menu

alt text


Instead, in Assets create new asset of type Renderer 2D Data (Create/Rendering/Universal Render Pipeline/2D Renderer), configure transparency in it's inspector and then use it as a default renderer in yout URP object.

alt text


1.png (26.6 kB)
screenshot-1.png (86.7 kB)
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

41 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 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

Making raycast ignore multiple layers 6 Answers

Newbie question. I have an object that is transparent to other objects in specific and I do not want it. 0 Answers

Customizable sprite character using multiple layers? 0 Answers

Pre rendered game (Resident evil Final Fantasy etc) 0 Answers

Animation layer playing on top of text box 0 Answers


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