Error codes CS1585 & CS1519

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();
}

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;
}
}

3 things:

  • When you post code, put it in code tags. It’s literally the second sticky post in the scripting forum that explains how
  • We don’t care or remember error codes. Errors have a human readable english description that is quite clear.
  • 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.

1 Like

Okay, that makes sense. Thanks.

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.

Rigidbody2D rb2D;
1 Like