Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Error in my code CS0119 "parsing" need some help

Discussion in 'Scripting' started by Ornix, Jun 23, 2014.

  1. Ornix

    Ornix

    Joined:
    Jun 22, 2014
    Posts:
    8
    here's my code

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class BulletIA : MonoBehaviour {
    5.     private float TimeAtual;
    6.     private float TimeDeletar;
    7.  
    8.     // Use this for initialization
    9.     void Start () {
    10.    
    11.     }
    12.    
    13.     // Update is called once per frame
    14.     void Update () {
    15.         transform.Translate (0, 0, 100 * Time.deltaTime);
    16.         TimeAtual += Time.deltaTime;
    17.  
    18.  
    19.         if (TimeDeletar >= 15) {
    20.                         Destroy (GameObject);
    21.                
    22.    
    23.     }
    24. }
    25.  
     
  2. NomadKing

    NomadKing

    Joined:
    Feb 11, 2010
    Posts:
    1,461
    Your if statement is either missing a closing bracket, or doesn't need the opening one. Depends which way you want look at it.
     
  3. smitchell

    smitchell

    Joined:
    Mar 12, 2012
    Posts:
    702
    Your if if statement isn't closed

    You need to add } on line 21
     
    Ornix likes this.
  4. Ornix

    Ornix

    Joined:
    Jun 22, 2014
    Posts:
    8
    error persist, now have somethings wrong with 20 line, i dont know what
     
  5. smitchell

    smitchell

    Joined:
    Mar 12, 2012
    Posts:
    702
    Your update needs to look like this

    Code (CSharp):
    1.     // Update is called once per frame
    2.     void Update () {
    3.         transform.Translate (0, 0, 100 * Time.deltaTime);
    4.         TimeAtual += Time.deltaTime;
    5.         if (TimeDeletar >= 15) {
    6.                         Destroy (GameObject);
    7.          }
    8.  
    9.     }
    10.  
     
    Ornix likes this.
  6. Ornix

    Ornix

    Joined:
    Jun 22, 2014
    Posts:
    8
    Thanks so much !