why its not working !!!

using UnityEngine;
using System.Collections;

public class PlayerController : MonoBehaviour
{
	
	public float maxSpeed = 30f;
	public int facingLeft = 0;
	
	Animator anim;
	public Transform RaycastPos;
	public LayerMask Obstacle;
	public Vector2 raycastDirection = -Vector2.right;
	public bool raycast = false;
	public RaycastHit2D hit

	void Start ()
	{
		anim = GetComponent<Animator> ();
	}
	 
	void Update ()
	{
		hit = Physics2D.Raycast (RaycastPos.position, raycastDirection, 0.1f)

		anim.SetFloat ("SpeedX", Mathf.Abs (rigidbody2D.velocity.x));
		anim.SetFloat ("SpeedY", Mathf.Abs (rigidbody2D.velocity.y));

		if(rigidbody2D.velocity.x != 0 || rigidbody2D.velocity.y != 0)
			rigidbody2D.AddForce(new Vector2(rigidbody2D.velocity.x*maxSpeed,rigidbody2D.velocity.y*maxSpeed));

		Raycast ();

	}
	void Right()
	{
		raycast = false;
		Raycast ();
		rigidbody2D.velocity = new Vector2 (maxSpeed, 0);
		transform.eulerAngles = new Vector3 (0, 180, 0); 
		facingLeft = 180; 
		raycastDirection = Vector2.right;
	}
	void Left()
	{
		raycast = false;
		Raycast ();
		rigidbody2D.velocity = new Vector2 (-maxSpeed, 0);
		transform.eulerAngles = new Vector3(0,0,0);
		facingLeft = 0;
		raycastDirection = -Vector2.right;
	}
	void Up()
	{
		raycast = false;
		Raycast ();
		rigidbody2D.velocity = new Vector2 (0, maxSpeed);
		transform.eulerAngles = new Vector3(0,0,-90);
		raycastDirection = Vector2.up;
	}
	void Down()
	{
		raycast = false;
		Raycast ();
		rigidbody2D.velocity = new Vector2 (0, -maxSpeed);
		transform.eulerAngles = new Vector3 (0, 0, 90);
		raycastDirection = -Vector2.up;
	}
	void Raycast()
	{
		if (hit.collider = "Obstacles" && !raycast)
		{
			rigidbody2D.velocity = new Vector2 (0, 0);
			raycast = true;
		}
		else
			Move ();
	}
	void Move()
	{
		if (anim.GetFloat ("SpeedX") == 0 && anim.GetFloat ("SpeedY") == 0) 
		{
			transform.eulerAngles = new Vector3(0,facingLeft,0);
			if (Input.GetKeyDown (KeyCode.D))
				Right();
			if (Input.GetKeyDown (KeyCode.A))
				Left ();
			if (Input.GetKeyDown (KeyCode.W))
				Up ();
			if (Input.GetKeyDown (KeyCode.S))
				Down ();
		}
		else
			return;
	}
}

You would get an exception/error in the RayCast method, you are setting a variable in the if, not comparing. If statements must include conditions that result in a true or false.

Your Code:

void Raycast()
{
    if (hit.collider = "Obstacles" && !raycast)
    {
        rigidbody2D.velocity = new Vector2 (0, 0);
        raycast = true;
    }
    else
        Move ();
}

Fixed(missing double equals):

void Raycast()
{
    if (hit.collider.name == "Obstacles" && !raycast)
    {
        rigidbody2D.velocity = new Vector2 (0, 0);
        raycast = true;
    }
    else
        Move ();
}

Furthermore, the collider object on hit is an object, you’re testing it’s equality to a string, did you mean to test “hit.collider.name” or “hit.collider.tag” against that string?