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 /
This question was closed Jan 21, 2014 at 11:16 PM by knuckles209cp for the following reason:

IT WORKS NOW I PUT THE PREFAB IN THE SCENE -___- SORRY

avatar image
0
Question by knuckles209cp · Jan 21, 2014 at 11:05 PM · instantiatetransformspawn

Wont let me instantiate gameobject when i destroy it?

Hi :) , i am trying to add a spawner , so when i press escape it comes up with a button that i can spawn zombies in , it works fine , but after i destroy it and click the spawn button again it doesn't let me spawn a zombie? my zombie is a prefab and it has a set spawn location . i HAVE to be able to destroy it

what do i have to do ??

MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object.

  if( GUI.Button(new Rect(10,150,150,50),"Spawn Zombie") ){
      
          
            Instantiate(ZombieObject, ZombieSpawn.transform.position, Quaternion.identity);
 
 
            }


YES i have done lots of research on this and all the other questions are not helping at all , they all have to do with timers and non of them are being destroyed . Please help me i am very stuck

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 Exalia · Jan 21, 2014 at 11:09 PM 0
Share

Where is the script you use to destroy your zombie

If your Zombie is saved as a prefab and you have dragged that prefab into the inspector as a public variable you should have no problem instantiating multiple zombies.

Can you be a little bit more specific in your question? Don't use the word "it" so much haha

avatar image robertbu · Jan 21, 2014 at 11:14 PM 0
Share

If your ZombieSpawn is a real prefab (i.e. it does not exist in the scene), then you should not have this problem. It appears you are using a scene item in your Instantiate().

http://docs.unity3d.com/Documentation/$$anonymous$$anual/Prefabs.html

avatar image knuckles209cp · Jan 21, 2014 at 11:14 PM 0
Share

i just realised how much i used it lol , ok ill give you the destroy script`var $$anonymous$$axHealth : int = 100;

var CurrentHealth : int = 0;

var Other : GameObject;

function Start () {

 CurrentHealth = $$anonymous$$axHealth;


}

function ApplyDamage (Damage : float) {

   if(CurrentHealth < 0){
   
      return;
   
   }


CurrentHealth -= Damage;

if(CurrentHealth == 0){

  $$anonymous$$oneyScript.Current$$anonymous$$oney += 50; 
   
  Destroy( gameObject );
  
  
  
   
   

}

}`

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

19 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

Related Questions

Spawning unique prefabs at different transform posititions 0 Answers

Place object randomly at any predefined spawn point 1 Answer

How to move a prefab to a gameobject position? 1 Answer

how do i know where my instantiated object came from? 2 Answers

Getting instance of an sub object rather than the original's subobject 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