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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Unity3d C#. Parsing error: Can't see the problem.

Discussion in 'Scripting' started by markrashera, Jun 5, 2015.

  1. markrashera

    markrashera

    Joined:
    Aug 15, 2014
    Posts:
    10
    Hello, i just started working on a new game, and i'm making the foot steps sounds. but something went wrong and i can't see what.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class FootStepSound : MonoBehaviour {
    5.     public AudioClip[] GroundSounds;
    6.     public string CurrentSurface;
    7.     // Use this for initialization
    8.     void Start () {
    9.    
    10.     }
    11.    
    12.     // Update is called once per frame
    13.     void Update () {
    14.         if (Input.GetKey ("W") || Input.GetKey ("A") || Input.GetKey ("S") || Input.GetKey ("D")) {
    15.             if(CurrentSurface == "Ground"){
    16.                 GetComponent<AudioSource>().PlayOneShot(GroundSounds[Random.Range(0,GroundSounds.Length));
    17.             }
    18.  
    19.         }
    20.     }
    21.  
    22.     void OnControllerColliderHit(ControllerColliderHit hit)
    23.     {
    24.         if (hit.transform.tag == "Ground") {
    25.             CurrentSurface = "Ground";
    26.         }
    27.     }
    28. }
    29.  
    I know it has something to do with the monodevelop and invisible things. And i tried copying the text into a different script, the same thing happens. this is the console error:
    Assets/FootStepSound.cs(29,1): error CS8025: Parsing error
     
  2. Limeoats

    Limeoats

    Joined:
    Aug 6, 2014
    Posts:
    104
    Your problem is on line 16. You missed a closing bracket. That line should read:

    Code (CSharp):
    1. GetComponent<AudioSource>().PlayOneShot(GroundSounds[Random.Range(0,GroundSounds.Length)]);
     
    markrashera likes this.
  3. markrashera

    markrashera

    Joined:
    Aug 15, 2014
    Posts:
    10
    Uhh thank you, I'm so stupid. so many brackets hh.
     
  4. Limeoats

    Limeoats

    Joined:
    Aug 6, 2014
    Posts:
    104
    No problem! It happens to all of us :)