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 Unity says that there is a error in the script but I don't find any errors

Discussion in 'Code Editors & IDEs' started by JamesvanGelda, Jun 8, 2022.

  1. JamesvanGelda

    JamesvanGelda

    Joined:
    Mar 7, 2022
    Posts:
    2
    Code (CSharp):
    1.  
    2. using System.Collections;
    3. using UnityEngine.Ui;
    4. using UnityEngine;
    5.  
    6. public class Game : MonoBehaviour
    7. {
    8.    public text ui;
    9.  
    10.    public void Increment()
    11.    {  
    12.        GameManager.Geld += GameManager.multiplier;
    13.    }
    14.  
    15.    public void Buy(int num)
    16.    {
    17.        if(num == 1 && GameManager.Geld >= 25)
    18.        {
    19.            GameManager.multiplier += 1;
    20.            GameManager.Geld -= 25;
    21.        }
    22.    }
    23.     }
    24.  
    25.     // Update is called once per frame
    26.     void Update()
    27.     {
    28.         ui.text = "Geld:" + GameManager.Geld;
    29.     }
    Thats the first script where the error is in.

    Code (CSharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5.  
    6. public class GameManager : MonoBehaviour
    7. {
    8.     public static int Geld;
    9.     public static int multiplier;
    10.     void Start()
    11.     {
    12.         multiplier = 1;
    13.         Geld = 0;
    14.        
    15.     }
    16. }
    17.  
    Thats the second script there is no error in it but I think it helps you to understand the problem
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    4,052
    And what is the error?
     
  3. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    4,052
    Oh, I can already see it. Check the braces …
     
  4. JamesvanGelda

    JamesvanGelda

    Joined:
    Mar 7, 2022
    Posts:
    2
    what are the braces ?
     
  5. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,195
    These guys
    upload_2022-6-9_13-59-31.png

    Oh and wrong subforum
     
  6. DelgadoUprep

    DelgadoUprep

    Joined:
    Jun 28, 2022
    Posts:
    9
    Since you're in the same topic, it says I'm missing ; on
    Assets\arrowpull.cs(11,8): error CS1002: ; expected

    Assets\arrowpull.cs(11,10): error CS1002: ; expected

    but I think I have them no?

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class arrowpull : MonoBehaviour
    6. {
    7.  
    8. private float CalculatePull(Vector3 pullPosition)
    9. {
    10. Vector3 pullDirection = pullPosition - start.position;
    11. Vector 3 targetDirection = end.position - start.position;;
    12. float maxLength = targetDirection.magnitude;
    13.  
    14. targetDirection.Normalize();
    15. float pullValue = Vector3.Dot(pullDirection, targetDirection) / maxLength;
    16. return Mathf.Clamp(pullValue, 0, 1);
    17. }
    18.  
    19.     // Start is called before the first frame update
    20.     void Start()
    21.     {
    22.        
    23.     }
    24.  
    25.     // Update is called once per frame
    26.     void Update()
    27.     {
    28.        
    29.     }
    30. }
     
  7. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    4,052
    Code (CSharp):
    1. Vector 3
    Space. The final frontier. :D