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