Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 rxx1 · Feb 10, 2021 at 07:46 PM · instantiateprefabcomponentnot workingrespawn

Prefab instantiates with its components disabled

 public class DeathCheck : MonoBehaviour
 {
     public GameObject paintBall;
     public GameObject expEffect;
     public GameObject newPlayer;
     public AudioSource splatSound;
     public Transform shotPoint;
     public Transform spawnPoint;
     public float ExpDeviation;    
 
     // Update is called once per frame
     void Update()
     {
         if (Input.GetButton("Fire1"))
         {
             Death();          
         }
     }
 
     void OnCollisionEnter2D(Collision2D collision)
     {
         if(collision.gameObject.tag == "Deadly")
         {
             Death();            
         }
         
     }
 
     void Death()
     {
         Destroy(gameObject);
         Debug.Log("Boom!");
         splatSound.Play();
 
         //Creates 20 balls with random rotations
         for (int i = 0; i < 20; i++)
         {
             float dev = Random.Range(-ExpDeviation/2, ExpDeviation/2);
             float rotZ = i * 18 + dev;
             transform.rotation = Quaternion.Euler(0f, 0f, rotZ);
             Instantiate(paintBall, shotPoint.position, transform.rotation);
         }
 
         //Explotion Effect
         Instantiate(expEffect, shotPoint.position, transform.rotation);
         Respawn();
                
     }
 
     void Respawn()
     {
         Instantiate(newPlayer, spawnPoint.position, Quaternion.identity);
     }
     
     
 }

Prefab's components are enabled alt text All the clone's components are disabled alt text

screenshot-2021-02-10-214022.png (50.6 kB)
screenshot-2021-02-10-213909.png (58.5 kB)
Comment
Add comment
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

3 Replies

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

Answer by rxx1 · Feb 12, 2021 at 06:50 AM

This thread explains what the problem could be. I can't test it now but I'll update this comment when I do

https://forum.unity.com/threads/instantiating-a-prefab-makes-disables-all-components.278471/

Comment
Add comment · 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
0

Answer by Megaboy238 · Feb 10, 2021 at 08:51 PM

Prefabs can have their components etc enabled on the surface but if you go into the Edit of the prefab they can be disabled there and that's the state they will enter the game. Double click the prefab to edit and check there.

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 rxx1 · Feb 11, 2021 at 12:55 PM 0
Share

Here's the prefab's config: alt text

screenshot-2021-02-11-145237.png (49.3 kB)
avatar image rxx1 · Feb 11, 2021 at 12:57 PM 0
Share

here's my prefab's config: alt text

screenshot-2021-02-11-145237.png (49.3 kB)
avatar image Megaboy238 · Feb 11, 2021 at 02:36 PM 0
Share

Do you take the prefab from the Hierarchy or from Assets, it may not make a difference but from the Hierarchy it might be trying to Instantiate the destroyed game prefab as so thinking it should be in that state Null. If not try drag drop prefab from Assets to inspector. $$anonymous$$aybe worth a try

avatar image rxx1 Megaboy238 · Feb 11, 2021 at 03:35 PM 0
Share

I take it from assets. the image above shows the inspector of the prefab

avatar image
0

Answer by murgonen · May 16 at 03:57 AM

For me, this happens when I think I drag-n-dropped a prefab reference to the field from the project hierarchy, but instead dragged it from the scene hierarchy.


It's very subtle thing, prefab changes propagate to the object and it seems identical in the Inspector, unless you click on on prefab field to see which one it highlights.

Comment
Add comment · 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

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

165 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 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

How to check if a component is on an instantiated prefab? 1 Answer

Get child component of a prefab to reference with another prefab 1 Answer

Removing A Component From An Instantiated Prefab After X More Are Instantiated 1 Answer

Instantiate prefab wihtout dragging prefab into gameObject script 9 Answers

Instantiating scripts with references to prefabs loses the reference. 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