The question is answered, right answer was accepted
Destroy Problem
THANKS IN ADVANCE Hi there i'm trying to write a script for my 2D RPG. in this script an object appears in front of the player, goes through an animation sequence before being destroyed however i am getting the smae three errors however i try to approach this. Hope u can help heres the script: using UnityEngine; using System.Collections;
 public class Freeze : MonoBehaviour {
 
     private Animator anmtr;
     private bool used;
 
     // Use this for initialization
     void Start () {
         anmtr = GetComponent<Animator> ();
         used = false;
     
     }
     
     // Update is called once per frame
     IEnumerator Update () {
         if (Input.GetKeyDown (KeyCode.Alpha1)) {
             anmtr.SetBool ("freeze", true);
             yield return new WaitForSeconds (1f);
             anmtr.SetBool ("freeze", false);
             used = true;
             }
     
     }
     void SelfDestruct () {
         if (used) {
             Destroy (GameObject);
         }
         
         
         
 }
 }
thanks again
Answer by meat5000 · Apr 04, 2016 at 01:35 PM
You need a lower case 'g' in
 Destroy (GameObject);
Update can not be a Coroutine, I do believe. Make a separate function and make that a coroutine, calling it from Update, instead.
Answer by Kurtisi · Apr 04, 2016 at 08:48 AM
Which errors does it show? What exactly is not working?
IEnumerator Update? Not quite sure...
 void Update () {
          if (Input.GetKeyDown (KeyCode.Alpha1)) {
              anmtr.SetBool ("freeze", true);
              yield return new WaitForSeconds (1f);
             StartCoroutine(WaitTime());
              }
      
      }
      void SelfDestruct () {
          if (used) {
              Destroy (GameObject);
          }
 
 IEnumerator WaitTime()
 {
              yield return new WaitForSeconds (1f);
              anmtr.SetBool ("freeze", false);
              used = true;
 }
Try this. Maybe it will help.
Sorry i could have sworn i put them there before. The three errors i was recieving before were the following:
- Freeze.cs(28,34): error CS0119: Expression denotes a 'type', where a 'variable', 'value' or 'method group' was expected 
- Freeze.cs(28,25): error CS1502: The best overloaded method match for 'UnityEngine.Object.Destroy(UnityEngine.Object)' has some invalid arguments 
- Freeze.cs(28,25): error CS1503: Argument '#1' cannot convert 'object' expression to type 'UnityEngine.Object' Luckily enough, thanks to your help i am no longer getting those errors however a single new one has appeared: "Freeze.cs(17,14): error CS1624: The body of - Freeze.Update()' cannot be an iterator block becausevoid' is not an iterator interface type" Do you know whats going wrong? I typed up exactly what you said.
Destroy (gameObject);
G shold be small, my mistake. That is my only solution...
Follow this Question
Related Questions
How to erase message after 3 seconds 1 Answer
Can't seem to get my animations to work proper 1 Answer
Can´t find the infinite loop in this script 0 Answers
My Animator and C-Sharp Bools won't work together? 0 Answers
Changing eye texture using bools 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                