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
1
Question by Sacrificer39 · Dec 14, 2011 at 07:54 PM · cameraprefabparentchild

How can I prevent position of a child transform to be hooked to the parent in a prefab?

Basically, I am working on a networking project with a top down view.

I have a prefab player object with all of my scripts attached.

The problem is, I have a code that I have made for the camera to follow the player, but since it is network code, I am trying to get the camera to spawn with the player prefab, but not take the position of the parent.

Things I have tried/attempted:

Having the camera in the scene rather than spawning.

Spawning a separate camera prefab.

Different ways to spawn the separate camera prefab..

Also, when I had it spawned separate, it was not correctly finding my player.

Things I will try after posting and keep updated:

I am going to try changing my cameras follow code rather than the camera finding the target, I will have the target find the camera.

Also, any other information on networking cameras would be greatly appreciated, thank you.

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 fafase · Dec 14, 2011 at 08:14 PM 0
Share

Next to the rotation, scale, position and hand in the left corner you have a button local global. I think it switches between the two, so that the object position is in the global world or the local world (parent world).

If I am wrong i will remove that comments.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Julien-Lynge · Dec 14, 2011 at 10:39 PM

I'm not sure I quite understand what you're doing, but your basic question "How can I prevent position of a child transform to be hooked to the parent in a prefab?" is easy to answer. A child transform is entirely relative to its parent - its position is relative to the parent position, its rotation is relative to the parent rotation, and its scale is relative to the parent scale. There is no way to 'uncouple' a child from its parent other than to remove the parent/child relationship. You can't do that within a prefab - you have to do it after the prefab is instantiated in scene. Here's how you uncouple a parent/child prefab:

Instantiate the prefab.

On the child, set 'transform.parent = null;' The child is no uncoupled - it has no parent.

Then, set the 'transform.position' to wherever you want it to be.

Just FYI, transforms and parenting have nothing to do with networking (I assume that by networking you mean "sending information over a network."

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 isteffy · Jul 25, 2016 at 08:52 AM 0
Share

I would downvote this if i could. This doesn't provide a solution as to how to reposition the child back to the position it would be if it were still attached to the parent.

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

6 People are following this question.

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

Related Questions

Make a simple tree 1 Answer

How to properly edit prefabs with child elements? 1 Answer

spawn prefabs as children of another game object 2 Answers

How to change position of child component without affecting the position of the parent 1 Answer

Instantiating prefabs as child of a gameobject 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