CS1526 & CS8032 error

Asked

Viewed 101 times

4

By error translation says I have to put a ")" at the end of "type" however now there is a ")" at the end of the "type" I tried to change to "[ ]" but it didn’t work I tried to put 2 ")" as I have seen in other codes but also did not work

Cs(14,71): error CS1526: A new Expression requires () or [] after type

the second mistake tried nothing.

Cs(14,93): error CS8032: Internal Compiler error During Parsing, Run with -v for Details

the code :

using UnityEngine;
using System.Collections;

public class Dinheiro : MonoBehaviour {

    public Vector2 velocity = new Vector2(0, -4);
    public Vector3 velocity3D = new Vector3(0, -4, 0);
    public float range = 4;

    // Use this for initialization
    void Start () {

        //rigidbody2D.velocity = velocity;
        transform.position = new Vector3(transform.position.x – range * Random.value, transform.position.y , transform.position.z);

    }



    // Update is called once per frame
    void Update () {
        transform.position += velocity3D * Time.deltaTime;
    }

}
  • 2

    Gives error in which line?

  • 1

    Are you sure you saved the file before trying to run again? Apparently it’s all right. Test by swapping line 14 for transform.position = new Vector3(0,0,0); and see if the error persists. Then add the rest little by little.

  • error is on line 14

  • 2

    Which is line 14, the number, we saw, but we have no way of knowing where it is. For me line 14 is a blank line. And no line has anything related to the error presented.

1 answer

2

Initially it seems all right, but I realized that the minus sign of the expression "Transform.position. x - range" is a little higher, I used the https://dotnetfiddle.net/ (https://dotnetfiddle.net/sp7ZCA) and he actually indicated error in this sign as unexpected character. And because of this he expects an open parenthesis closes of the constructor, fix this character with the '-' right that should work well!

Look at the comparison:

transform.position.x – range //Seu sinal de menos
transform.position.x - range //Sinal de menos correto
  • +1 Very well observed! :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.