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 Muhwu · Jun 05, 2015 at 10:18 PM · transformlinerenderersorting layers

Line Renderer and Sprite Z-coordinate always 10?

This is the weirdest thing. I set the sprite's Z coordinate in every update. I check it at the start and at the end, but it is always 0 when I print out the transform.position. However, when I look in the inspector, the Z coordinate for this object is always a 10. I never manually set the value to any other than a 0, yet it is a 10.

This causes an issue. I use LineRenderer to render some lines and setting "Sorting Layer" on the Line Renderer appeared to have no effect on where it was rendered and thus, I'm using the Z coordinate. However, it magically turning into 10 is weird. Furthermore, the actual sprite being rendered is a child object of the magic object that goes to 10. (Weirdest part is that before and after the Update that moves the object, the value appears to be correct).

Anyone ran into anything like this before? I could give out some code, but I don't even know what's relevant here. Setting the position is always done with

 this.transform.position = new Vector3(x, y, 0);
Comment
Add comment · Show 1
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 Muhwu · Jun 05, 2015 at 10:30 PM 0
Share

Yeah, that appears to be the issue, thanks! (If you post that as an answer ins$$anonymous$$d of a comment, I'll accept it as an answer). Didn't realize the parent objects had Z coordinates other than 0.

1 Reply

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

Answer by maccabbe · Jun 05, 2015 at 10:23 PM

Does the sprite have a parent? The inspector displays the local coordinates while transform.position sets the global coordinates. To set the localPosition use transform.localPosition, i.e.

 transform.localPosition=new Vector3(x, y, 0);
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

20 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

Related Questions

Line render from an object to a click 0 Answers

Line renderer rotation and alignment 1 Answer

how to find a point(vector2) between two points(Vector2) of a line (line renderer) 2 Answers

Change Script so that the object's position can be modified in the Editor/through other scripts? 1 Answer

How to diappear a line renderer from start and end position of line 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