Search Unity

Bug I do not understand where I have the error, writes that cs(22,30): CS1002 error: ; expected although

Discussion in 'Burst' started by kachmamy, Jan 28, 2023.

  1. kachmamy

    kachmamy

    Joined:
    Nov 15, 2022
    Posts:
    3
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class Cases : MonoBehaviour
    6. {
    7.    public bool openCase = false;
    8.    public GameObject prefabs;
    9.    public GameObject sp;
    10.  
    11.    void Start(){
    12.  
    13.    }
    14.    
    15.    void Update(){
    16.  
    17.    }
    18.  
    19.    public void caseBttn(int caseint)
    20.     {
    21.         openCase = true;
    22.         GameObject SetActive == (true);
    23.         simulaeCases();
    24.     }
    25.     void simulaeCases()
    26.     {
    27.         for(int a = 0; a < 40; a++)
    28.         {
    29.             int rand = Random.Range(0, 1000);
    30.             int randWeapon = 0;
    31.             if(rand <= 400)
    32.             {
    33.                  randWeapon = 0;
    34.             }
    35.             else if(rand > 400 && rand <= 600)
    36.             {
    37.                 randWeapon = 1;
    38.             }
    39.             else if(rand > 600 && rand <= 850)
    40.             {
    41.                 randWeapon = 2;
    42.             }
    43.             else if(rand > 850)
    44.             {
    45.                 randWeapon = 3;
    46.             }
    47.             GameObject obj = instantiate(prefabs[randWeapon],new Vector2(0,0),Quaternion.identity) as GameObject;
    48.             obj.transform.SetParent(sp.transform);
    49.             obj.transform.localScale = new Vector2(1,1);
    50.         }
    51.     }
    52. }
     
  2. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,445
    The error message part that says "(22,30)" means "I think the error is around line 22, column 30."

    C# code is case-sensitive. "GameObject" does not mean the same thing as "gameObject", and "instantiate" does not match "Instantiate". You need to follow tutorial text more exactly.

    GameObject SetActive == (true);
    makes no sense. I think you mean
    gameObject.SetActive(true);
    but I have no idea what your goal is here.

    There may be other issues with your code.
     
  3. kachmamy

    kachmamy

    Joined:
    Nov 15, 2022
    Posts:
    3
    I didn't understand you, please tell me in more detail, I just wanted to make a case simulator and found a splint on YouTube, I've reviewed it several times, our scripts are no different:\