Basically i wrote a small bot script and it works but i need the enemy to always point towards the soldier, how would i do this, heres my code:
using UnityEngine;
using System.Collections;
public class BOT : MonoBehaviour {
public GameObject Soldier;
public GameObject Enemy;
public float Distance=100f;
public Rigidbody bulletPrefab;
public GameObject EnemyBarrelEnd;
public GameObject gun;
private Vector3 SoldierPos=new Vector3(0,0,0);
// Update is called once per frame
void Update ()
{
SoldierPos=Soldier.transform.position;
Enemy.transform.position=Vector3.Lerp(Enemy.transform.position, Soldier.transform.position,Time.deltaTime);
animation.Play("soldierRun");
Distance=Vector3.Distance(Enemy.transform.position,Soldier.transform.position);
if (Distance<=5)
{
animation.Play("soldierFiring");
Rigidbody rocketInstance;
rocketInstance = Instantiate(bulletPrefab, EnemyBarrelEnd.transform.position, bulletPrefab.transform.rotation) as Rigidbody;
rocketInstance.AddForce(Vector3.forward*10000);
}
}
}