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
0
Question by coquinounet · Jul 10, 2014 at 07:49 PM · depth

Depth with Unity2D

Hello I'm making a Beat'em Up and i'm trying to do "depth" for example if an enemy is lower on the screen than you on the screen, he appers like if he was in front of you and when he go higher, he goes back you. I've tried to use Sorting layers but there is something who is every on the top layer. (Just in case, my player is animated in game) So what should I do ? Thanks

Edit : I made a video to explain : https://www.youtube.com/watch?v=vdSrmYqhpWg

Comment
Add comment · Show 6
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 tanoshimi · Jul 11, 2014 at 08:52 AM 1
Share

Generally speaking, objects that are closer to the camera will always be rendered "on top" of objects that are further away. So to add "depth", don't fake it by adjusting the height (y), adjust the actual depth (z) relative to the camera.

avatar image coquinounet · Jul 11, 2014 at 05:33 PM 0
Share

Yes but if I use Sorting layer with a Sprite, no matter what depth (z) I use, it will be ever on the top

avatar image JusticeAShearing · Jul 12, 2014 at 04:12 PM 0
Share

Surely if one wants depth (z coordinate), one would use Unity 3D as oppose to 2D?

If not, please specify, because if I am to help you, I need more information to get my head around a 2D-3D paradox.

avatar image coquinounet · Jul 12, 2014 at 05:59 PM 0
Share

Well look at this video of my game, you see that my player is on the top but Z axis change and it's doing nothing https://www.youtube.com/watch?v=X6QJm8NVisg

avatar image JusticeAShearing · Jul 13, 2014 at 04:22 PM 0
Share

I now see what you mean. Thank you for specifying. I will try to write a script for you, but I'm being held behind schedule by a tree chopping issue, so please be patient.

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by alwayscodeangry · Jul 12, 2014 at 11:36 PM

Putting all your character SpriteRenderers in the same sorting layer and then setting their sortingOrder based on their y position should have the desired effect.

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 coquinounet · Jul 13, 2014 at 09:25 PM 0
Share

Well no, i've already tried this but the player is composed of many Sprites so there is a special order

avatar image
0

Answer by Corentin · Jul 13, 2014 at 09:37 PM

I did something similar (I can paste the script but there are some game-specific things inside), and just changed z position according to y position. if it's high on the screen (y), make it farther (z)

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 coquinounet · Jul 14, 2014 at 11:40 AM 0
Share

That's nit the solution, my player is made of many sprites which are sorted with Sorting Layer optuon in the Sprute Component and if I change Z axis it will do nothing

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

7 People are following this question.

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

Related Questions

GUI.depth factors 1 Answer

Using a Pre-Rendered Depth Mask? 3 Answers

From flat image to pseudo-3D, how to manage a texture/depth map couple ? 0 Answers

shader that includes texture, normal, and depth map 1 Answer

Shader - Writing to Depth issues 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