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 sonatkaran · Jul 21, 2014 at 09:28 AM · rotationparent-childaffect

How to prevent affect of parents rotation on child

Hi, I searched similar questions and most of them gave this piece of code for answer :

  Quaternion rotation;
  
  void Awake()
  {
       rotation = transform.rotation;
  }
  
  void LateUpdate()
  {
        transform.rotation = rotation;
  }

But its not my answer. My problem is; I want to remove rotation affect which is provided by parent. So any other object or function can change transforms rotation.

Edit: (My Scenerio) :

In my game I used camera path and camera moves on a path while moving an object(vehicle) must follow the camera but only positional followign i dont want to rotate vehicle with camera.

Comment
Add comment · Show 2
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 Tehnique · Jul 21, 2014 at 09:33 AM 0
Share

Why are you parenting objects if you don't want to move/rotate them together? It seems you would be better off parenting your children to another object that just moves along with the ex-parent.

avatar image sonatkaran · Jul 21, 2014 at 09:43 AM 0
Share

I couldn't explain my question nicely so I edited my question.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by dsada · Jul 21, 2014 at 11:20 AM

Instead of parenting the camera try to create a script that moving them just as the camera moves.

 public class CameraFollow : MonoBehaviour
 {
    public Camera camera //assign the camera in inspector or in Start()
    private Vector3 prevPos;
 
    void Start()
    {
       prevPos = camera.transform.position;
    }
 
    void Update()
    {
       Vector3 displacement = camera.transform.position - prevPos;
 
       prevPos = camera.transform.position;
 
       this.transform.positon += displacement;
    }
 }

and put this script on the object you would like to keep the distance from camera

Comment
Add comment · Show 2 · 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 sonatkaran · Jul 21, 2014 at 11:57 AM 0
Share

I tried that before it works but this time they were not updating same time and because of that reason vehicle vibrating and we cant get smooth vision. I Solved this question by using duplicated camera path. Thanks anyway.

avatar image Wolfdog · Jul 21, 2014 at 01:40 PM 0
Share

There is a script in the standard asset folder which you can import to do the job. I think it was called 'mouseorbit' without quotes. Let me know if that's what you're looking for or if it works for you.

avatar image
0

Answer by haim96 · Jul 21, 2014 at 01:51 PM

use a script like suggested but put the camera movment in Lateupadet() instead of updtae(). that should do the trick...

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 sonatkaran · Jul 22, 2014 at 01:49 PM 0
Share

I tried but problem is same but as I said I solved by using duplicated camera path. Thanks.

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 is a child object not rotating properly with parent? 1 Answer

Why do grouped Terrain objects move together but don't rotate as one? 1 Answer

Simple Script Problem 1 Answer

children doesn't take parent's rotation, position or scale. 1 Answer

Having difficulty with Parent Object rotation and Child Object movement. 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