monster AI movement

I’ve been working on my rouguelike for a bit now, trying to get my monster AI working like I want it to. just like in my last thread, the monsters should move one step when the player moves one step. I’m having some problems with my code in which the monsters don’t move at all.

my monster manager:

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class basicmob : MonoBehaviour {
	public List<GameObject> moblist = new List<GameObject>();
	public GameObject monster;
	public GameObject mob;	
	public static int monsters;
	public GameObject newspawn;
	public Mobhelper script;
	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
		if(ControllerScript.counter>5   monsters<10){
			GameObject[] mobPosition;
			mobPosition= GameObject.FindGameObjectsWithTag("room");
			var mobPlace=Random.Range(0,mobPosition.Length);
			Transform target= mobPosition[mobPlace].transform;
		    newspawn=(GameObject)Instantiate(mob, target.position+(Vector3.up/2), target.rotation) ;
			moblist.Add(newspawn);
			ControllerScript.counter=0;
			monsters++;
			if(ControllerScript.nextturn==true){
				foreach(GameObject monster in moblist){
				script.turnProcedure();
				}
				ControllerScript.nextturn=false;
			}
		}
	}
}

and the monsters themselves:

using UnityEngine;
using System.Collections;


public class Mobhelper : MonoBehaviour {
	private float speed=1.0f;
	public GameObject player;
	private Vector3 mobEnd;
	private bool mobMove;
	void Start(){
	}
	
	void Update(){
	}
	
	public void turnProcedure(){
		
			patrol();
	}
		void attack(){
		}
		void chase(){
	}
	void patrol(){
		if(ControllerScript.nextturn){
		var chance=Random.Range (1,4);
		 bool hittingForward=false;
       if(Physics.Raycast(transform.position, Vector3.forward, 1)){
         hittingForward=true;
       }
         bool hittingRight=false;
       if(Physics.Raycast(transform.position, Vector3.right, 1)){
         hittingRight=true;
       }
         bool hittingLeft=false;
       if(Physics.Raycast(transform.position, Vector3.left, 1)){
         hittingLeft=true;
       }
         bool hittingBackwards=false;
       if(Physics.Raycast(transform.position, -Vector3.forward, 1)){
         hittingBackwards=true;
       }
 
       if (mobMove  (transform.position == mobEnd)){
         mobMove = false;
         }
       if(!mobMove  chance==1  hittingForward==false){
        mobMove = true;


         mobEnd = transform.position + Vector3.forward;
       }
       if(!mobMove  chance==2  hittingRight==false){
         mobMove = true;


         mobEnd = transform.position + Vector3.right;
       }
       if(!mobMove  chance==3  hittingLeft==false){
         mobMove = true;

         mobEnd = transform.position + Vector3.left;
       }
       if(!mobMove  chance==4  hittingBackwards==false){
         mobMove = true;

         mobEnd = transform.position - Vector3.forward;
       }
       transform.position = Vector3.MoveTowards(transform.position, mobEnd, Time.deltaTime * speed);
	}	
	ControllerScript.nextturn=false;
	}
}

I’m assuming there’s something wrong with the foreach loop because the function itself works fine when i call it from the update function within the monsters script. And is this even a good way for monster AI to work as I have it so far. I’ve seen some interesting ways to move AI monsters, especially from Tinykeep, but I got to get over this hurdle first. Thanks in advance.:smile:

I should also mention I’m working in c#