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 Heke · Jun 25, 2013 at 12:43 PM · prefabchildcloth

how to make prefab clone as a child of prefab clone?

Okay I have browsed half of the internet trying to solve this simply issue. Im trying to make already cloned prefab instantiate another prefab clone and the instantiated clone as a child of the clone that instantiated it.

 var lazor : Transform;
 ...
     if(Input.GetAxis("shoot")){
         object = Instantiate(lazor, transform.position, Quaternion.Euler(0, 0, 180));
         object.parent = transform;
 ...
 }

This code was in a prefab. When I instantiate the object, everything is ok, but when I add the line "object.parent = transform" it disappears even from the hierarchy. (it doesn't even appear in hierarchy but appears then when I use yield WaitForSeconds.)

Tell me if you need more explanation. Thanks!

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 slayer29179 · Jun 25, 2013 at 12:48 PM 0
Share

This may not work but try the word var in front of object = instantiate.... It may work :)

avatar image Imankit · Jun 25, 2013 at 12:50 PM 1
Share

use object.transform.parent = transform;

avatar image Heke · Jun 25, 2013 at 01:05 PM 0
Share

I already tried both of those

avatar image MissingSemicolon · Jun 25, 2013 at 02:31 PM 0
Share

Could you post the rest of the function/class?

avatar image Heke · Jun 25, 2013 at 02:47 PM 0
Share

Here keep in $$anonymous$$d that it only disappears when I try to set the parent. otherwise it just instantiates it.

oh and there's one block that destroys everything that hits it, but it wasn't the causer because I tested it with debug.logs

Show more comments

0 Replies

· Add your reply
  • Sort: 

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

18 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

Related Questions

Make a simple tree 1 Answer

Separate different kind of prefab/enemy ? 0 Answers

How can I access the 2nd tier of children on a prefab in the Project Folder Window? 4 Answers

Putting a variable of a child in the inspector for the parent 1 Answer

How to Instantiate Prefab as Child of Player OnTriggerEnter 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