Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
1
Question by ThomasQ · Aug 03, 2011 at 09:14 PM · childskybox

How to not let Child object rotate with Parent

Hi!

How do I make a child object move along with the parent object, but don't let rotate?

I ask this question specificly for the Cube / Mobile skybox. When the cube is a child of the camera, it obviously moves along with it, but it shouldn't rotate..

Anyone got an idea?

Thanks in advance!!

Comment
Add comment · Show 3
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 ThomasQ · Aug 03, 2011 at 09:29 PM 0
Share

I made this script, but it's real jerky, and I can't believe there isn't an easier way :D Thoughts?

 function Update () {
 var Camera = GameObject.Find("$$anonymous$$ain Camera");
 transform.position=Camera.transform.position;}
avatar image SilverTabby · Aug 03, 2011 at 09:58 PM 1
Share

Don't use GameObject.Find to grab the main camera. It's already easily and quickly available in Camera.main.

avatar image Bunny83 · Aug 04, 2011 at 12:58 AM 0
Share

You really, really shouldn't use a classname as variable name. "Camera" is a class, when you call your variable the same you can get in trouble.

1 Reply

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

Answer by Waz · Aug 03, 2011 at 09:53 PM

Do as per your comment, but after you move the camera (eg. in LateUpdate) to prevent jerking:

 function LateUpdate()
 {
     transform.position = Camera.main.position;
 }

Of course, if for some reason you are changing the camera position in LateUpdate (scripts often do this in order so that the camera tracks the latest position of, say, the player), then you'll need to modify call order. IIRC, OnPreCull is called after LateUpdate, so you could use that too.

Alternatively, just do the work in your camera positioning script:

 ...
 transform.position = ...
 skybox.position = transform.position;
Comment
Add comment · Show 4 · 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 ThomasQ · Aug 03, 2011 at 10:00 PM 0
Share

Thanks! But could you clarify a bit? Ins$$anonymous$$d of Function Update I should use LateUpdate? The script itself is by the way a big strain for the mobile phone. Can't the same effect be reached by editing the shader, and if so, will that run faster or slower?

avatar image Waz · Aug 03, 2011 at 11:48 PM 0
Share

Yes, doing GameObject.Find every frame is not a good idea, mobile or otherwise.

avatar image ThomasQ · Aug 04, 2011 at 12:25 AM 0
Share

So, is it correct then that the mobile skybox does rotate with the camera, and therefor doesn't rotate on screen? In essence it's just a cube with a shader on it, and how you move it is up to us? Thanks though for the answers guys!

avatar image ThomasQ · Aug 04, 2011 at 11:38 AM 0
Share

Actually: It should be:

So

 function LateUpdate()
 {
 transform.position = Camera.main.transform.position;
 }


It is still Very shakey, but that may be due to the camera script. I'll test it out tonight!

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Why are the default Skyboxes really low quality on mobile (iOS)? 2 Answers

Make a simple tree 1 Answer

How to Create Cube Skybox Texture 2 Answers

How can I hide HDRI skybox view from my game view but still get its lighting features in realtime? 1 Answer

How to made a normal skybox with a rectangle part of solid color 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