Hi guys ! i have roblem with minion AI sctipts. they are to fast and they are gouing around the target. i was doing jessEtzeler0’s tutorials on youtube from art when he makes Dota style camera.
here’s code from script if that is problem :S
var target : Transform;
var rotationSpeed = 5;
var myTransform : Transform;
var canMove : boolean = true;
var inCombat : boolean = false;
var fireSpell : Transform;
function Awake()
{
myTransform = transform;
}
function Start()
{
target = GameObject.FindWithTag("node2").transform;
}
function Update () {
var moveSpeed = Random.Range(30,80);
//check to make sure not being attack. if attacked then inCombat = true. applies to both enemy players and other minions.
//if no enemy no longer in distance continue towards tower. inCombat == false
//head to the tower if no enemy is in range or been attacked
if(canMove == true inCombat == false TowerScript.tower1destroyed == false) {
myTransform.rotation = Quaternion.Slerp(myTransform.rotation,
Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed*Time.deltaTime);
myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;
}
//if incombat == true then target / attack nearest enemy
}
//trigger while stay. Attack tower. If enemies come close then attack enemies instead so switch to inCombat
//towers not dead then keep attacking tower
function OnTriggerEnter (col : Collider) {
if(col.gameObject.tag == "tower1trigger") {
Debug.Log("entered tower1");
if(TowerScript.tower1destroyed == false) {
canMove = false;
Instantiate(fireSpell,this.transform.position,Quaternion.identity);
}
}
}