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 CaryMic · May 22, 2013 at 08:25 AM · 2dsprite

Unity 2DToolKit sprite sort problem

I use Unity with 2DToolKit to develop a 2d game. Now I have two sprites(A and B) in the scene and they have the same Z value. How can I put A on the front of B or put B on the front of A ?

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

1 Reply

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

Answer by Fattie · May 22, 2013 at 08:26 AM

For beginners:

Simply move the game object forwards or backwards ... that is to say nearer or closer the camera. Click on the game object (the sprite) in your editor. notice the red, green, blue arrows. Grab one of the arrows to move the object. For beginner articles, try unityGEMS.com, it's great !


For badass 2.5D developers:

This is a core concept in 2.5D games: you have all the colliders on one layer .. say z=10, for example. You actually have the sprites separate, on their different layers .. perhaps 15 and 16 in the example.


However, there is a simple, clever trick to get you by in many situations:

http://answers.unity3d.com/questions/307540/is-it-possible-to-cast-a-ray-but-ignore-z-position.html

Step one, your two sprites put them on slightly different layers .. say 5 and 6 for example.

BUT in fact make the colliders REALLY DEEP ... say 5 deep.

then it will still work perfectly.

To make it clearer for you when working in the editor, simply change the position by a small amount (perhaps 0.05) but make sure the colliders are, say, 2 deep.

Recall that -- of course -- you will have the various rigidbody locked-off so they can only rotate on Z, or depending on your game, likely not rotate at all, and not move back and fore on Z.

Pls vote up that answer ...

http://answers.unity3d.com/questions/307540/is-it-possible-to-cast-a-ray-but-ignore-z-position.html

if it is useful to you, as it is a critical trick in 2.5D games!

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 CaryMic · May 22, 2013 at 08:50 AM 0
Share

Two sprites need collision detection, so two sprites must have the same Z value. How can I sort the sequence without changing the Z value ?

avatar image Fattie · May 22, 2013 at 09:22 AM 0
Share

Gotchya @Cary ... see edit !

avatar image CaryMic · May 22, 2013 at 11:54 AM 0
Share

Thks, I understand it and your solution is perfect !

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

14 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

Related Questions

Rotating a sprite distorts it? 0 Answers

SpriteRenderer change order in layer in edit mod via script 1 Answer

Custom 2D armor slots 1 Answer

make rain with sprite sheet in unity2d 2 Answers

SetTangentMode of Spline not working through code 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