Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 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 imicz08 · Mar 07 at 08:18 PM · errorinstantiatebugbug-perhapshow

Could someone help me with instantiate function? It's not working. Weird.

 void generateEnimies() {
         foreach(int i in Enumerable.Range(0, 10))
         {
             var clone = Instantiate(enime);
             clone.SetActive(true);
             clone.transform.position = new Vector3(0, 0, 0);
         }
         Debug.Log(e);
     }

why doesn't it work if enime != null and function is definitely called (I checked) Edit: there are no errors, nothing is spawned, but the instantiated object exists(how?) if you call debug.log. There is no new game objects and nothing new in hierarchy. Enemy is enemy prefab that I want to instantiate.

Comment
Add comment · Show 3
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 CleeDotExe · Mar 07 at 11:10 PM 0
Share

What's the error message given?

Also, instantiate has multiple inputs, but I don't know what Enime refers to. if it refers to an object, you'd have to fill in the position and others too. There are a lot of ways to use instantiate, as clearly stated in the documentation. you might have to define everything you want first if you haven't done that, there's no way for the script to know what enime is. Also, quick little thing, enime is either anime or enemy.

avatar image sacredgeometry · Mar 07 at 11:37 PM 0
Share

Enemy is spelled Enemy btw.

avatar image Monsoonexe · Mar 08 at 04:00 AM 0
Share

What do you mean "it's not working"? Is the thing being spawned in the wrong place? Check the Hierarchy for something like GameObject (clone). If you see something with (clone), it means Instantiate worked.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by barry1251 · Mar 08 at 11:40 AM

And the simple pool is just basically instantiating these objects and putting them into a pool. MyLabCorp Patient Portal

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 imicz08 · Mar 08 at 03:08 PM 0
Share

What do you mean, add clone to some kind of list? @barry1251

avatar image
0

Answer by grimreefer24601 · Mar 08 at 06:02 PM

It sounds to me like Instantiate is returning a null. If Instantiate fails for any reason it will produce a null value. It should throw an error message in the editor, but won't stop running necessarily. Have you stepped through the code in the debugger? I''d put a breakpoint at line 5 in your code; and see if the clone has any data of if it's null.

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 imicz08 · Mar 08 at 07:56 PM 0
Share

Function is returning a proper game object that should(theoretically) be displayed in hierarchy and be in the scene. I also checked the scene, and it is scene that I looked in while trying to find this weird gameobject @grimreefer24601

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

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

Gun Switching Error 1 Answer

Why does unity3D crash when starting this script in play mode? 1 Answer

when pressing play gameobject get deleted and the game breaks 0 Answers

Setting the parent of a transform which resides in a prefab error 1 Answer

[Closed]NullReferenceException on Object Instantiation onto game world 2 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