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

What's wrong with this code ?

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

  1. Ornix

    Ornix

    Joined:
    Jun 22, 2014
    Posts:
    8
    Im new here and speak a little english, sorry for some error
    I need some help with this code, somethings wrong



    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class AK47AI : MonoBehaviour {
    5.  
    6.     public ParticleSystem Particula;
    7.  
    8.     // Use this for initialization
    9.     void Start () {
    10.         Particula.enableEmission = false;
    11.    
    12.     }
    13.    
    14.     // Update is called once per frame
    15.     void Update () {
    16.         if (Input.GetKey (KeyCode.Mouse0))  (
    17.                   Particula.enableEmission = true; )
    18.          else (
    19.                   Particula.enableEmission = false;
    20.         )
    21.  
    22.    
    23.     }
    24. }
    25.  
     
  2. ElvisAlistar

    ElvisAlistar

    Unity Technologies

    Joined:
    Oct 2, 2013
    Posts:
    226
  3. ScriptingPaul

    ScriptingPaul

    Joined:
    Dec 8, 2013
    Posts:
    10
    Your if else statement is surrounded by () where it should be {}
     
    Ornix likes this.
  4. Ornix

    Ornix

    Joined:
    Jun 22, 2014
    Posts:
    8
    could you leave an exemple?
     
  5. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    Code (CSharp):
    1.  void Update ()
    2. {
    3.         if (Input.GetKey (KeyCode.Mouse0))
    4.         {
    5.                   Particula.enableEmission = true;
    6.          }
    7.          else
    8.           {
    9.                   Particula.enableEmission = false;
    10.            }  
    11. }
     
    Ornix likes this.
  6. Ornix

    Ornix

    Joined:
    Jun 22, 2014
    Posts:
    8
    VERY THANKS !