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
0
Question by kevinmrn · Apr 06, 2013 at 08:36 PM · instantiateclonestartup

Instantiate loops until unity crashes...

Hey I'm trying to instantiate an object but all it seems to do is keep making clones until unity crashes. I only need 3 clones. What am I doing wrong?

 void Start () 
 {
     rotation.x = Random.Range(-0.1600f, -0.2200f);
     int startrot = Random.Range(0, 360);
     
     transform.rotation =  Quaternion.Euler(startrot, 0, 0);
     // Array 0=0 1=1 ... 9=9
     for(int i = 0; i < 10; i++)
     {
         myDegrees[i]=270-(36*i);
         Debug.Log("InputArray" + myDegrees[i]);
     }

     
     for(int c = 0; c < 3; c++)
     {
         Instantiate(prefab, new Vector3 (37, 0, 0), Quaternion.identity);//as Transform;
         Debug.Log ("c= " + c);
     }
     
 }
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 kevinmrn · Apr 06, 2013 at 11:33 PM

Hey SirVictory,

Thanks for your reply, I did the same thing as you just made a new prefab and restarded, and its fixed now. Just redid the prefab. The problem was that it just kept making clones in an endless loop for no reason. Bug? :).

Cheers man!

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 SrBilyon · Apr 06, 2013 at 11:35 PM 0
Share

I suppose so :D Those kind of things happen every now and then.

avatar image
1

Answer by SrBilyon · Apr 06, 2013 at 08:47 PM

Weird. I tried the spawning code from above, and don't seem to be having that problem.

 using UnityEngine;
 using System.Collections;
 
 public class Spawner : MonoBehaviour {
 
     public GameObject prefab;
     void Start()
     {
         for (int c = 0; c < 3; c++)
         {
             Instantiate(prefab, new Vector3(37, 0, 0), Quaternion.identity);//as Transform;
             Debug.Log("c= " + c);
         }
     }
 }

It spawns all three prefabs for me. Are you getting any warnings?

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
1

Answer by binoculars88 · Aug 21, 2017 at 01:44 PM

Maybe your script was attached to the initial prefab? Every copy got the script attached to them again, so they keep copying themselves...

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

13 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

Related Questions

Assigning gameobject to an instantiated prefab through script? 2 Answers

How to Instantiate and change velocity 2 Answers

How could I save all cloned objects in a scene, and load them back up on start? 1 Answer

Instantiating a GameObject from scene that changes 1 Answer

What can I do to make the objects I instantiated move with the background? 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