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 /
  • Help Room /
This question was closed May 01, 2017 at 06:20 PM by Gamerdrill for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Gamerdrill · Oct 25, 2016 at 01:23 AM · instantiateparentproblema

Parent Problem

Personally, I have a big problem,

I am instantiating an object, and all good, instantiating normally, however when I put him in parent, it is in parent correctly, the problem is that it changes position.

Already tried: // Sets "newParent" as the new parent of the player GameObject. player.transform.SetParent (newParent);

And also I tried: // Makes the GameObject "newParent" the parent of the GameObject "player". player.transform.parent = newParent.transform;

I can not understand what's happening, because the biggest problem is it was working perfectly, and do not know what I modified.

Help me.

Comment
Add comment · Show 6
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 seckincengiz · Oct 25, 2016 at 01:38 AM 0
Share

If you use "transform.localposition" Positions are relative to the parent game object's position, so when you try to instantiate your gameobject, it calculates the position relative to it's parent object. This answer may help you.

avatar image hexagonius · Oct 25, 2016 at 10:16 AM 0
Share

It's possible that the position of your prefab changed from all 0 to some value (which is annoying sometimes). These values are used when the object is instantiated. Further note: If e.g. the prefab has an x value of 10 and should use that when childed to a GO as its local position value, use the SetParent method with the second parameter set to false (this is default for assembling UI)

avatar image Gamerdrill · Oct 25, 2016 at 10:18 AM 0
Share

I tried to do that, but he does not recognize this command line. I have to add some library "using"?

avatar image hexagonius Gamerdrill · Oct 25, 2016 at 10:32 AM 0
Share

It's an ordinary Trasform method. You can check the syntax here
https://docs.unity3d.com/ScriptReference/Transform.SetParent.html

avatar image Gamerdrill hexagonius · Oct 25, 2016 at 08:40 PM 0
Share

the problem is that we have tried to do that way too, and even then the object appears in a very distant place, he saw the son, but the father ends up going to where it instantiates.

this is my script: if (Objetoem$$anonymous$$aos == null) {

             Obj$$anonymous$$ = Instantiate (Inventory.ObjPrefab [NS], Position$$anonymous$$.position, Position$$anonymous$$.rotation) as GameObject;
             Obj$$anonymous$$.transform.parent = PositionD$$anonymous$$.transform;

if I remove the parent command, the object appears exactly in the right place, but the object is a weapon and must accompany the camera.

Show more comments

1 Reply

  • Sort: 
avatar image
0
Best Answer

Answer by Gamerdrill · Oct 26, 2016 at 05:55 PM

very personal,

not solved my problem, but I will try to do something, as we say here in Brazil, "make a kludge" what goes well I post here. I thank everyone and if anyone has any more idea can send.

I believe my prefab is wrong in some way, because when I put a cube zeroed in place, it works perfectly.

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 seckincengiz · Oct 26, 2016 at 09:46 PM 0
Share

Where did you create that prefab? Go there and check the pivot point of your model. In $$anonymous$$aya you can center the pivot point and clear the history. You can also check your object's pivot point in Unity by changing the tool handle placement buttons (see image below). I think you have already tried all of these but worth to try.!alt text

image.png (20.3 kB)
avatar image Gamerdrill seckincengiz · Oct 27, 2016 at 12:34 PM 0
Share

$$anonymous$$an, I think I wiggled it around when I was doing the prefab, I try to make another prefab later and see if I have not done anything wrong. Thanks

Follow this Question

Answers Answers and Comments

87 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 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Setting a parent of instantiated object negate all axis 1 Answer

Can't Instantiate an object as child of another 1 Answer

Instantiating as a child of an object in hierarchy 1 Answer

How to set lots of Instantiate prefab Gameobjects in the same parent? 1 Answer

Child with Rigidbody doesn't move with Parent with Rigidbody 3 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