How to create a 2D grid based array with passable/impassable grids for movement ?

How can I create a 2D array that allows movement through only the lanes, but not the dark grey blocks as in the picture below ?
I tried using rigidbody and colliders and the result is plain terrible, as the sphere resembles a woodpecker drilling into a branch everytime there is a collision.

Thanks for taking a look into this.

The code that I’m using to move in a grid like fashion is given below:

using UnityEngine;
using System.Collections;

public class ControllerScript : MonoBehaviour {
	public float speed = 1.0f;
	
	private Vector3 endpos;
	private bool moving = false;
	
	void Start () {
		endpos  = transform.position;
	}
	
	void Update () {
		if (moving && (transform.position == endpos))
			moving = false;
		
		if(!moving && Input.GetKey(KeyCode.W)){
			moving = true;
			endpos = transform.position + Vector3.up;
		}

		if(!moving && Input.GetKey(KeyCode.S)){
			moving = true;
			endpos = transform.position + Vector3.down;
		}

		if(!moving && Input.GetKey(KeyCode.A)){
			moving = true;
			endpos = transform.position + Vector3.left;
		}

		if(!moving && Input.GetKey(KeyCode.D)){
			moving = true;
			endpos = transform.position + Vector3.right;
		}
		
		transform.position = Vector3.MoveTowards(transform.position, endpos, Time.deltaTime * speed);
	}
}

@bubzy replied to the question with an example. Going through it all made a lot of sense and helped a lot. Here is his reply.

I don’t usually do this but http://westwalescse.net/unity/arrayDemo.rar take a look, theres a few annoying things with positioning and whatever, but the idea is there.

it really does look as though you could do with brushing up on your coding a little bit though, this is bread-and-butter logic :slight_smile: