Question by
furqonzt99 · Dec 05, 2015 at 06:09 PM ·
arrayai
how in order to pursue many targets?
he will pursue the object with the tag "Enemy" (coins) and if he meets the coins, the coins will disappear and he will pursue other coins?
my script single target :
using UnityEngine;
using System.Collections;
public class AICharacterBehaviour : MonoBehaviour {
public GameObject target;
public float movingSpeed = 2f;
public float turnSpeed = 0.05f;
void Update() {
Vector3 gapPosition = target.transform.position - this.transform.position;
gapPosition = new Vector3(gapPosition.x, 0, gapPosition.z);
Quaternion lookRotation = Quaternion.LookRotation(gapPosition);
this.transform.rotation = Quaternion.Lerp(this.transform.rotation, lookRotation, turnSpeed);
this.transform.Translate(Vector3.forward * movingSpeed * Time.deltaTime);
}
}
Comment
Your answer
Follow this Question
Related Questions
Need assistance with an primitive AI. 0 Answers
How to store interaction using Hashtable and use AI to act on it 0 Answers
Genetic Algorithm OverflowException: Number overflow: 1 Answer
Choosing non null values from arrays for pathfinding 2 Answers
How to create a list that changes based on variables 2 Answers