void Start() { playerSpeed = speedBuffer.Length - 2; player = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerFollowers>(); idleTarget = RandomTarget(transform.position); initialPosition = transform.position; }
void Start() { InitialPosition = transform.position; initialRotation = transform.rotation; InitialForward = transform.forward; playerFollowers = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerFollowers>(); segmentSize = MoraneSegment.transform.localScale.z * 0.9f; }
void Start() { initialPosition = transform.position; if (maxChaseDistance < 10) { throw new Exception("maxChaseDistance has to be larger than 10"); } playerFollowers = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerFollowers>(); animator = GetComponent <Animator>(); Navigator nav = GameObject.FindGameObjectWithTag("Navigator").GetComponent <Navigator>(); //System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch(); //stopWatch.Reset(); //stopWatch.Start(); Transform path = transform.parent.FindChild("Path"); Vector3[] milestones = new Vector3[path.childCount + 1]; milestones[0] = transform.position; for (int i = 0; i < path.childCount; i++) { milestones[i + 1] = path.GetChild(i).transform.position; } for (int i = 0; i < milestones.Length; i++) { Vector3 from = milestones[i]; Vector3 to = milestones[(i + 1) % milestones.Length]; List <Vector3> localPath; try { if (nav.TryFindPath(from, to, out localPath)) { patrolPath.AddRange(localPath); } else { Debug.Log("Path not found NOTHING SHOULD WORK", path.GetChild(i % milestones.Length)); } } catch (Exception e) { Debug.Log(e); Debug.Log("Path not found NOTHING SHOULD WORK", path.GetChild(i)); } } state = State.PATROL; //stopWatch.Stop(); //TimeSpan ts = stopWatch.Elapsed; SetPathPoint(); }