void Update() { players = bot.GetCollidingObjects(); foreach (var obj in players) { if (obj == null) { continue; } distance = Vector3.Distance(transform.position, obj.transform.position); if (distance < min_distance) { min_distance = distance; min_dist = obj; } } if (min_dist != null && Vector3.Distance(transform.position, min_dist.transform.position) <= bot_agr_range) { target = min_dist.transform; transform.LookAt(target); if (anim.isPlaying == false) { anim.Play("Take 001"); } transform.position = Vector3.MoveTowards(transform.position, min_dist.transform.position, stats.bot_move_speed * Time.deltaTime); } else { min_dist = null; min_distance = float.MaxValue; } }
void Update() { players = bot.GetCollidingObjects(); foreach (var obj in players) { distance = Vector3.Distance(transform.position, obj.transform.position); if (distance < min_distance) { min_distance = distance; min_dist = obj; } } if (current_point == points.Length) { current_point = 0; } distance = Vector3.Distance(transform.position, points[current_point].position); if (distance <= 0) { current_point++; } transform.LookAt(points[current_point].position); transform.position = Vector3.MoveTowards(transform.position, points[current_point].position, boss_speed * Time.deltaTime); if (min_dist != null && Vector3.Distance(transform.position, min_dist.transform.position) <= boss_agr_range && Vector3.Distance(transform.position, min_dist.transform.position) >= 5f) { transform.position = Vector3.MoveTowards(transform.position, min_dist.transform.position, boss_speed * Time.deltaTime); } }
void Update() { players = bot.GetCollidingObjects(); foreach (var obj in players) { distance = Vector3.Distance(transform.position, obj.transform.position); if (distance < min_distance) { min_distance = distance; min_dist = obj; } } var range = GetComponentInChildren <SphereCollider>(); if (min_dist != null && Vector3.Distance(transform.position, min_dist.transform.position) <= range.radius) { transform.position = Vector3.MoveTowards(transform.position, min_dist.transform.position, stats.bot_move_speed * Time.deltaTime); } else if (min_dist != null && Vector3.Distance(transform.position, min_dist.transform.position) >= range.radius) { min_dist = null; min_distance = float.MaxValue; } // else if (bot_hp.healthp <= 6) // transform.position = Vector3.MoveTowards(transform.position, min_dist.transform.position * 4f, stats.bot_move_speed * Time.deltaTime); }