void Update() { raycastOut(); if (inMotion) { if (Mathf.Abs(this.transform.position.x - next.transform.position.x) < 0.1f && Mathf.Abs(this.transform.position.z - next.transform.position.z) < 0.1f) { inMotion = false; this.current = next; this.current.probability = 0; } else { this.transform.Translate(direction); //direction = new Vector3(Time.deltaTime * (next.transform.position.x - this.transform.position.x), 0f, Time.deltaTime * (next.transform.position.z - this.transform.position.z)); } } else if (!inMotion && this.current.NextCell() != -1) { inMotion = true; next = this.current.neighbor[this.current.NextCell()]; next.DiffuseProb(); direction = new Vector3(Time.deltaTime * (next.transform.position.x - this.transform.position.x), 0f, Time.deltaTime * (next.transform.position.z - this.transform.position.z)); } }