Search Unity

Unexpected symbol "SetCountText"

Discussion in 'Scripting' started by gavdownes, Aug 27, 2014.

  1. gavdownes

    gavdownes

    Joined:
    Aug 27, 2014
    Posts:
    2
    Hi there. Brand new to Unity. Currently doing the second beginner tutorial "Stealth". As per the tutorial, I am calling the function "CheckTargetIntensity". However the 'unexpected symbol' error is highlighting the underlined bolded section. Both the call and the function are spelled the same as one is copy/pasted from the other. Why is the called name wrong when in the "Roller ball tutorial" the same format is used? Hovering the mouse over the first "CheckTargetIntensity" brings up a little link that points to the function, so clearly they are spelled the same and it is recognised. Argh! Thank you in advance.

    {
    public float fadeSpeed = 2f;
    public float highIntensity = 2f;
    public float lowIntensity = 0.5f;
    public float changeMargin = 0.2f;
    public bool alarmOn;
    private float targetIntensity;
    void Awake()
    {
    light.intensity = 0f;
    targetIntensity = highIntensity;
    }
    void Update()
    {
    if (alarmOn)
    {
    light.intensity = Mathf.Lerp (light.intensity, targetIntensity, fadeSpeed * Time.deltaTime)
    CheckTargetIntensity();
    }
    else
    light.intensity=Mathf.Lerp(light.intensity, 0f, fadeSpeed * Time.deltaTime);
    }

    void CheckTargetIntensity()
    {
    if(Mathf.Abs(targetIntensity - light.intensity) < changeMargin)
    {
    if(targetIntensity == highIntensity)
    targetIntensity = lowIntensity;
    else
    targetIntensity = highIntensity;
    }
    }
    }

    The format for the Roller ball tutorial was
    void Start()
    {
    count=0;
    SetCountText();
    }
    void SetCountText()
    {
    countText.text = "count: " + count.ToString();
    }
     
  2. Limeoats

    Limeoats

    Joined:
    Aug 6, 2014
    Posts:
    104
    Change this line:
    Code (CSharp):
    1. light.intensity = Mathf.Lerp (light.intensity, targetIntensity, fadeSpeed * Time.deltaTime)
    To:
    Code (CSharp):
    1. light.intensity = Mathf.Lerp (light.intensity, targetIntensity, fadeSpeed * Time.deltaTime);
    It needs a semicolon at the end.
     
  3. gavdownes

    gavdownes

    Joined:
    Aug 27, 2014
    Posts:
    2
    Ugh you have got to be kidding me! So funny. A friend said directly over the phone "are you missing a comma or something?" My response... "No" She is going to pay on me something fierce. Got to love rookie mistakes.
    Thank you
     
  4. Limeoats

    Limeoats

    Joined:
    Aug 6, 2014
    Posts:
    104
    You're welcome.
    We have all made this mistake many times. After awhile you'll recognize certain compiler errors and know exactly where to look and what to look for.