zombie AI won't work

hello,

i want to make an AI how can walk and detect walls in c#, i thought i got it but it gives errors.

pleas help

this is the code :

using UnityEngine;
using System.Collections;

public class AI_Zombie_Controller : MonoBehaviour {

	public float turnspeed = 2;
	public float walkspeed = 3;
	public float distanceTOwall = 2;
	public RaycastHit hit;

	void Update () {
	if(Physics.Raycast(transform.position, transform.forward, hit, distanceTOwall, 0)){
			transform.Rotate(Vector3.up, 90 * turnspeed * Time.deltaTime);
			}
	else{
			transform.Rotate(Vector3.up ,-90 * turnspeed * Time.deltaTime);	
			}
	transform.Translate(Vector3.forward * walkspeed * Time.deltaTime);			
	}
}

thanx

Have you tried the AI code from the FPS example project? I think it’s the best solution in your case.

Sorry, but i dont think this is the best solution