Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question error CS1026

Discussion in 'Editor & General Support' started by UnusedLasagna, Jul 16, 2023.

  1. UnusedLasagna

    UnusedLasagna

    Joined:
    Jul 15, 2023
    Posts:
    1
    I do not understand the error, any help would be appreciated. Unity said it was something in the bottom line but I cannot figure it out.

    Error Message: Assets\PipeSpawnScript.cs(35,124): error CS1026: ) expected

    Code (csharp):
    1.  using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class PipeSpawnScript : MonoBehaviour
    6. {
    7.     public GameObject pipe;
    8.     public float spawnRate = 2;
    9.     private float timer = 0;
    10.     public float heightOffset = 10;
    11.     // Start is called before the first frame update
    12.     void Start()
    13.     {
    14.         spawnPipe();
    15.     }
    16.  
    17.         // Update is called once per frame
    18.         void Update()
    19.     {
    20.         if (timer < spawnRate)
    21.         {
    22.             timer = timer + Time.deltaTime;
    23.         }
    24.         else
    25.         {    spawnPipe();
    26.              timer =0;
    27.         }
    28.     }
    29.     void spawnPipe()
    30.     {
    31.         float lowestPoint = transform.position.y - heightOffset;
    32.         float highestPoint = transform.position.y + heightOffset;
    33.      
    34.      
    35.         Instantiate(pipe, new Vector3(transform.position.x, Random.Range(lowestPoint, highestPoint), 0, transform.rotation);
    36.     }
    37.  
    38. } [CODE]
     
    Last edited: Jul 16, 2023
  2. BABIA_GameStudio

    BABIA_GameStudio

    Joined:
    Mar 31, 2020
    Posts:
    483
    Neither do we as the error code is basically useless for us. Update your post to show the whole script (as what you have posted is barely comprehensible as it is incomplete), and make sure you use code tags (there is a guidelines topic about doing this).

    Then, post the exact error message so we can actually help you.
     
  3. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    1,833
    Everything @BABIA_GameStudio says is correct.

    I will say the last line is missing a
    )
    .