Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Resolved Error codes CS1585 & CS1519

Discussion in 'Getting Started' started by Bucketson, Jun 2, 2024.

  1. Bucketson

    Bucketson

    Joined:
    Jun 2, 2024
    Posts:
    2
    For some reason, error codes listed in the title of the post appeared in a movement script I was designing, and even after removing the causes of the errors, new ones popped in its place. I attempted brute forcing it but it didn't work.
    Here's the script:

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class PlayerMovement : MonoBehaviour
    {
    public float movementSpeed = 3.0f;

    Vector2 movement = new Vector2();

    Rigidbody2D = rb2D

    private void Start()
    {
    rb2D = GetComponent<Rigidbody2D>();
    }

    private void Update()
    {
    //Temporalily empty, more will be added soon, as this is the framework.
    }

    void FixedUpdate()
    {

    movement.x = Input.GetAxisRaw("Horizontal");
    movement.y = Input.GetAxisRaw("Vertical");

    movement.Normalize();

    rb2D.velocity = movement * movementSpeed;
    }
    }
     
  2. Bunny83

    Bunny83

    Joined:
    Oct 18, 2010
    Posts:
    4,261
    3 things:
    1. When you post code, put it in code tags. It's literally the second sticky post in the scripting forum that explains how
    2. We don't care or remember error codes. Errors have a human readable english description that is quite clear.
    3. When you get errors, you usually get a line and even column number telling you exactly where the error occured. You get this information for free. So when you need help solving YOUR errors, at least share this information.
    The actual error is either in the line that the compiler complains about, or above as the compiler also reads your code top to bottom, left to right. You seem to messed up your "rb2D" declaration big time. You're missing a semicolon at the end and also have an equals sign that makes no sense. I would tell you the line number, if your code was actually posted in a code block.

    ps: When you edit your post, please make sure you copy your original code. Missing code formattingi usually messes up the formatting and can even alter some of the code as it's mis interpreted.
     
    Last edited: Jun 2, 2024
    Ryiah likes this.
  3. Bucketson

    Bucketson

    Joined:
    Jun 2, 2024
    Posts:
    2
    Okay, that makes sense. Thanks.
     
  4. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,937
    C# doesn't tend to be very good at determining some kinds of errors, and if you have multiple errors on the same line it can become confused. The line where you define the
    Rigidbody2D
    field is the problem in the posted code.

    Code (csharp):
    1. Rigidbody2D rb2D;
     
    Bunny83 likes this.