I have followed this tutorial to make robots and make them shoot:
http://unity3d.com/support/old-resources/tutorials/fpstutorial
I tried outcommenting everything that seemed logical to make the robots move while they shoot. But I cant seem to find any clue. Right now they stop everytime the robot is close to a player to shoot.
basically what happens is this.
function AttackPlayer () {
var lastVisiblePlayerPosition = target.position;
while (true) {
if (Vector3.Distance(transform.position, target.position) < attackRange) {
var hit : RaycastHit;
if (Physics.Linecast (transform.position, target.position, hit))
hit.transform == target;
// Target is dead - stop hunting
if (target == null)
return;
// Target is too far away - give up
var distance = Vector3.Distance(transform.position, target.position);
// Debug.Log(distance + “>” + (shootRange * 3));
if (distance > shootRange * 3)
return;
lastVisiblePlayerPosition = target.position;
RotateTowards(target.position);
var forward = transform.TransformDirection(Vector3.forward);
var targetDirection = lastVisiblePlayerPosition - transform.position;
targetDirection.y = 0;
// Debug.Log(distance + “<” + shootRange + " " + angle + “<” + shootAngle);
// Start shooting if close and play is in sight
if (distance < shootRange)
yield StartCoroutine(“Shoot”);
}
And the shoot is :
function Shoot () {
// Start shoot animation
animation.CrossFade(“shoot”, 0.3);
// Wait until half the animation has played
yield WaitForSeconds(delayShootTime);
// Fire gun
BroadcastMessage(“Fire”);
// Wait for the rest of the animation to finish
yield WaitForSeconds(animation[“shoot”].length - delayShootTime);
}