i have been following along a tutorial series on how to make a 2d game (Very simple). I have done exactly as the video says, compared code and they are identical but i get this error? “warning CS0414: The field ‘PlayerController.movement’ is assigned but its value is never used” i would appreciate any help. Here is the code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour {
public float speed = 5f;
private float movement = 0f;
private Rigidbody2D rigidBody;
// Start is called before the first frame update
void Start() {
rigidBody = GetComponent<Rigidbody2D> ();
}
// Update is called once per frame
void Update() {
}
}
The warning is just a warning. You have a variable X, and you set X = something, but nowhere else in the code seems to care about it. It’s saying you have some gas in the tank, but you never drive the car. This could point to a mistake you may have made with your logic.
If this is your code and you don’t want to use that variable X, get rid of it.
If it’s in an asset script you downloaded, or you have future plans for the variable, you can put the following line somewhere near the top of the offending script:
#pragma warning disable 0414 // assigned but never used