Missing Parenthase.. Parenthasi?

The code says “) expected”
But there is a ‘)’…
here is the code

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Button_Contrl : MonoBehaviour {
    GameObject colorbutton1;
    public bool pressed1;

    // Use this for initialization
    void Start () {
       
    }
   
    // Update is called once per frame
    void Update () {
        if (pressed1 == true) {
            transform.localScale = (0, 0, 0);
        }
    }
}

@milo55545 , try this:

transform.localScale += new Vector3(0.1F, 0, 0);

It’s a misleading error. Even if you fixed it, you’d immediately have another (the real) error.

The problem is that the expression you’re trying to assign to localScale is malformed, and does not have the correct type (or any comprehensible type, for that matter). What you’re looking for is:

transform.localScale = new Vector3(0, 0, 0);

Without the “new Vector3”, C# is not expecting a comma separated list inside the parentheses. Hence, when it hits the first comma, it complains that it expected the opening parenthesis to be closed so that it could have a single value to work with, rather than the unexpected comma that it does not know how to handle. But if you simply had (0), it would complain that the expression (an integer) cannot be converted to a Vector3. So the real solution is to let C# know up front exactly what the data type of the expression on the right side of the assignment will be.

It is supposed to set the scale to 0 but it does nothing now…
Never mind it was a problem with a boolean, thanks!

Glad to hear you fixed it. I copied and pasted and didn’t even notice the 0.1f in the first field.

Also note that

transform.localScale = new Vector3(0, 0, 0);

Can be written as

transform.localScale = Vector3.zero;
2 Likes