Why create two of the same variables?

Hello!
I am following a tutorial for C# in which we make a variable called Vector3 Move. Then in Update we write Vector3 Move = new Vector3(Input.GetAxis(“Horizontal”), 0, Input.GetAxis(“Vertical”));
The tutorial does not seem to explain why we define these two separate variables with the same name, but they don’t seem to correspond. I have even noted out the top Vector3 Move and the script works the exact same. I am sure there is a reason to write it like this but I don’t know what it is.

Here is the tutorial video:

Here is my script:

using UnityEngine;
using System.Collections;
[RequireComponent(typeof(Rigidbody))]
public class PlayerMove : MonoBehaviour {
    public Rigidbody rb;
    public int PlayerSpeed = 10;
    public float maxSpeed = 5.0f;
    public bool grounded = false;
    public GameObject floor;
    Vector3 Move; //?? Why do this if Vector3 Move is done in update also?

    void Start()
    {
        rb = GetComponent<Rigidbody>();

    }
    void Awake()
    {

    }

        void Update()
        {
            Vector3 Move = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
            //This works just fine without the first Vector3??

            if (rb.velocity.magnitude < maxSpeed)
            {
                rb.AddForce(Move * PlayerSpeed);
            }
        }

Those two variables have nothing to do with each other as they are defined in seperate scopes. Since your Move variable which you define inside Update is only used in Update it’s actually correct to make it a local variable.

Since the class variable Move is a private variable it can only be accessed from within this script. If you don’t use it, it’s completely pointless.

I had a quick look at the video you linked, but i can’t really see the code you posted here. In tutorials (and software development in general) scripts and classes often undergo a lot refactoring and changes over time. You either do not use the latest code (so it might be a variable which is intended to be used later or it is left over from a recent refactoring) or the author simply forget to remove it.

Anyways in your code the class variables “grounded”, “floor” and “Move” are all not used in this class. Since grounded and floor are public they might be used by other components, but since they currently aren’t used in this class they should most likely be removed.