Search Unity

Resolved error CS1002: ; expected

Discussion in 'Scripting' started by Vitin_9336, May 27, 2020.

  1. Vitin_9336

    Vitin_9336

    Joined:
    May 27, 2020
    Posts:
    34
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using System.Collections.Specialized;
    4. using System.Security.Cryptography;
    5. using UnityEngine;
    6.  
    7. public class Bullet : MonoBehaviour
    8. {
    9.     [Header("BulletConfig")]
    10.     public int range;
    11.     public int damage;
    12.     public float mass;
    13.     public float speed;
    14.     [Header("Imports")]
    15.     public PlayerController player;
    16.     public ParticleSystem impact;
    17.  
    18.     //Privates
    19.     private Rigidbody rb;
    20.     private Vector3 origin;
    21.  
    22.     void Start()
    23.     {
    24.         rb.GetComponent<Rigidbody>();
    25.         origin = transform.position;
    26.     }
    27.    
    28.     void Update()
    29.     {
    30.         //Massa
    31.         rb.mass = mass;
    32.  
    33.         //Frente
    34.         Vector3 horizontal transform.right * 0;
    35.         Vector3 horizontal transform.forward * 1;
    36.         Vector3 velocity = (horizontal + vertical).normalized * speed;
    37.         rb.movePosition(rb.position + velocity * Time.FixedDeltaTime);
    38.  
    39.         //Range
    40.         if (Vector3.Distance(orgin, transform.position) > range)
    41.         {
    42.             Destroy(gameObject);
    43.         }
    44.  
    45.     }
    46.  
    47.     private void OnCollisionEnter(Collision collision)
    48.     {
    49.         Destroy(gameObject);
    50.         Instantiate(impact, collision.transform.position, collision.transform.rotation, collision.transform);
    51.     }          
    52. }
     
  2. Vitin_9336

    Vitin_9336

    Joined:
    May 27, 2020
    Posts:
    34
    HOW DO I DELTE THIS THREAD?
     
  3. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    You forgot the = signs on lines 34-35

    In the future, paste the error message into your post, as it includes more information than just what's on the first line.
     
  4. Vitin_9336

    Vitin_9336

    Joined:
    May 27, 2020
    Posts:
    34
    upload_2020-5-27_15-37-0.png
    what i do now?
     
  5. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,909
    The same thing as your last 8-10 errors. Check your that your spelling and capitalization is correct.
     
  6. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
  7. Vitin_9336

    Vitin_9336

    Joined:
    May 27, 2020
    Posts:
    34
    and the other errors?
     
  8. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,738
    Take a deep breath and read through this. Your life will become much easier here in Unity.

    How to report problems productively in the Unity3D forums:

    http://plbm.com/?p=220
     
    Joe-Censored likes this.
  9. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    Most of them are exactly the same problem. We're not going to hold your hand through every single one of them, because if you can't learn to solve this (which is by far the easiest of all possible bugs to solve) on your own, there's only so much that we can help you.

    The one on line 35 is a different problem, that one is because you have created two variables named "horizontal". Remove one of the two lines.
     
  10. Vitin_9336

    Vitin_9336

    Joined:
    May 27, 2020
    Posts:
    34
    now there's a error with the "Rigidbody" and the "movePosition"
     
  11. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,738
    You are not even trying. Capitalization and spelling and punctuation must be 100% correct. Pay close attention or you are wasting your own time.
     
  12. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    I'm gonna stop answering questions from you where the answer is "capitalization", because you REALLY need to learn how to fix that yourself.
     
  13. Vitin_9336

    Vitin_9336

    Joined:
    May 27, 2020
    Posts:
    34
    javascript is easier, i'll keep on 2D games, bye
     
    Joe-Censored and Kurt-Dekker like this.
  14. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Proper capitalization is just as important to Javascript as it is to C#. Basically the same rules you're struggling with here apply to JS. Good luck though.
     
    Vryken, Vitin_9336 and StarManta like this.
  15. davidnibi

    davidnibi

    Joined:
    Dec 19, 2012
    Posts:
    426
    You can’t just give up like that! :eek:
     
    Joe-Censored and Vitin_9336 like this.
  16. Vitin_9336

    Vitin_9336

    Joined:
    May 27, 2020
    Posts:
    34
    it was a joke, i waste 3 hours to make that code, i'm not gonna throw it away :T
     
    Joe-Censored likes this.
  17. Vitin_9336

    Vitin_9336

    Joined:
    May 27, 2020
    Posts:
    34
    i like to waste my time with stupid things ;)
     
    Last edited: May 28, 2020
  18. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Glad to hear you're not giving up. Question though, is your code editor not suggesting the correct spelling/case of these things as you type them? (You using VS?)
     
    Vitin_9336 likes this.
  19. Vitin_9336

    Vitin_9336

    Joined:
    May 27, 2020
    Posts:
    34
    Ye, i'm using Visual Studio. One thing i know is that when i try to type "Vector3" it keeps auto-correcting to "BitVector32"
     
  20. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Might be an issue with the VS tools for Unity plugin then. Make sure that is installed, and make sure when you open the script in VS that you are doing so by double clicking the script from within Unity instead of just opening the script outside of Unity. This should ensure that Unity is generating the VS solution and opening it correctly, so VS is aware of what is in the rest of the project.

    Some info from Microsoft on the tools plugin if you need to install or reinstall it.
    https://docs.microsoft.com/en-us/vi...th-visual-studio-tools-for-unity?view=vs-2019
     
    Vitin_9336 likes this.
  21. Vitin_9336

    Vitin_9336

    Joined:
    May 27, 2020
    Posts:
    34
    Ok
     
  22. davidnibi

    davidnibi

    Joined:
    Dec 19, 2012
    Posts:
    426
    You can install code snippets - I’ve completely removed the C# one and have the unity one there instead. I kept getting obscure references pop up.
     
  23. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,909