Search Unity

IF Statements, unexpected error

Discussion in 'Scripting' started by Annro, Jan 25, 2015.

  1. Annro

    Annro

    Joined:
    May 31, 2014
    Posts:
    5
    Hi, guys. I'm somewhat new to C# so I've been following the tutorials on the Learn page.
    I've run into this error: Assets/Scripts/CoffeeTemp.cs(28,17): error CS1525: Unexpected symbol `}'

    This is the code I've written... I've added tons of indentation to make it easy to read, but I still can't figure it out:


    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class CoffeeTemp : MonoBehaviour {
    5.  
    6.     float coffeeTemp = 85.0f;
    7.     float coffeeHotLimit = 70.0f;
    8.     float coffeeColdLimit = 45.0f;
    9.  
    10.     void Update ()
    11.     {
    12.         if (Input.GetKeyDown (KeyCode.Space))
    13.             Debug.Log (TempTest);
    14.    
    15.         coffeeTemp -= Time.deltaTime * 5f;
    16.     }
    17.  
    18.     void TempTest()
    19.     {
    20.         if (coffeeTemp > coffeeHotLimit)
    21.         {
    22.             print("The coffee is too hot!");
    23.         }
    24.  
    25.         else if (coffeeTemp < coffeeColdLimit)
    26.         {
    27.             print("The coffee is too cold!")
    28.         }
    29.  
    30.         else
    31.         {
    32.             print("The coffee's just right... Drink up!");
    33.         }
    34.     }
    35. }
    36.  
    I'm sure it's fairly easy to sort out, but a few tips from the experts wouldn't hurt.
    Thanks!
     
  2. Annro

    Annro

    Joined:
    May 31, 2014
    Posts:
    5
    No need to answer! It seems I've forgotten a semicolon... Silly me xD