'Top-down motion with Unity causing errors

I am a first time programmer watching a tutorial on making a 2d, top-down game. My goal for this specific section of code is just to make the player walk around and collide with blocks and other characters. The tutorial I'm following is "Learn Unity Engine and C# by creating a real top down RPG" on Udemy and I don't see anyone else having the same problem.

Here was the working code before I added collisions:

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

public class player : MonoBehaviour
{
    private BoxCollider2D boxCollider;

    private Vector3 moveDelta;

    private void Start()
    {
        boxCollider = GetComponent<BoxCollider2D>();
    }

    private void FixedUpdate()
    {
        float x = Input.GetAxisRaw("Horizontal");
        float y = Input.GetAxisRaw("Vertical");

        //Reset moveDelta
        moveDelta = new Vector3(x, y, 0);

        //Swap sprite direction for left or right
        if (moveDelta.x > 0)
            transform.localScale = Vector3.one;
        else if (moveDelta.x < 0)
            transform.localScale = new Vector3(-1, 1, 1);
    }
}

Now here it is with the collisions:

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

public class Player : MonoBehaviour
{
    private BoxCollider2D boxCollider;
    private Vector3 moveDelta;
    private RaycastHit2D hit;

    private void Start()
    {
        boxCollider = GetComponent<BoxCollider2D>();
    }

    private void FixedUpdate()
    {
        float x = Input.GetAxisRaw("Horizontal");
        float y = Input.GetAxisRaw("Vertical");

        //Reset moveDelta
        moveDelta = new Vector3(x, y, 0);

        //Swap sprite direction for left or right
        if (moveDelta.x > 0)
            transform.localScale = Vector3.one;
        else if (moveDelta.x < 0)
            transform.localScale = new Vector3(-1, 1, 1);

        //Make sure we can move in this direction by casting a box there. If box returns null, free to move.
        hit = physics2D.BoxCast(transform.position, boxCollider.size, 0, new Vector2(0, moveDelta.y), Mathf.Avs(moveDelta.y * Time.deltaTime), Layermask.GetMask("Actor", "Blocking"));
        if (hit.collider == null)
        {
            //Make it move
            transform.Translate(0, moveDelta.y * Time.deltaTime, 0);
        }
        hit = physics2D.BoxCast(transform.position, boxCollider.size, 0, new Vector2(moveDelta.x,0), Mathf.Avs(moveDelta.x * Time.deltaTime), Layermask.GetMask("Actor", "Blocking"));
        if (hit.collider == null)
        {
            //Make it move
            transform.Translate(moveDelta.x * Time.deltaTime, 0, 0);
        }


    }
}

I am given 8 errors:

Assets\player.cs(31,15): error CS0103: The name 'physics2D' does not exist in the current context
Assets\player.cs(31,109): error CS0117: 'Mathf' does not contain a definition for 'Avs'
Assets\player.cs(31,144): error CS0103: The name 'Layermask' does not exist in the current context
Assets\player.cs(37,15): error CS0103: The name 'physics2D' does not exist in the current context
Assets\player.cs(37,108): error CS0117: 'Mathf' does not contain a definition for 'Avs'
Assets\player.cs(37,143): error CS0103: The name 'Layermask' does not exist in the current context
Unable to parse file Library/LastSceneManagerSetup.txt: [Control characters are not allowed] at line 0
Invalid file content for Library/StateCache/SceneView/496fa5-mainStage.json. Removing file. Error: System.ArgumentException: JSON parse error: The document is empty.
  at (wrapper managed-to-native) UnityEngine.JsonUtility.FromJsonInternal(string,object,System.Type)
  at UnityEngine.JsonUtility.FromJson (System.String json, System.Type type) [0x00062] in C:\buildslave\unity\build\Modules\JSONSerialize\Public\JsonUtility.bindings.cs:50 
  at UnityEngine.JsonUtility.FromJson[T] (System.String json) [0x0000c] in C:\buildslave\unity\build\Modules\JSONSerialize\Public\JsonUtility.bindings.cs:33 
  at UnityEditor.StateCache`1[T].GetState (System.String key) [0x00087] in C:\buildslave\unity\build\Editor\Mono\Utils\StateCache.cs:90 
UnityEditor.SceneView:OnEnable()
UnityEditorInternal.InternalEditorUtility:LoadSerializedFileAndForget(String)
UnityEditor.WindowLayout:LoadWindowLayout(String, Boolean) (at C:/buildslave/unity/build/Editor/Mono/GUI/WindowLayout.cs:495)

From what I have been able to find, the name is declared in the wrong block of code?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source