private void Fire() { if (projectilePrefab) { StraightFlyEnemy firedProjectile = Instantiate(projectilePrefab, transform.position, Quaternion.identity) as StraightFlyEnemy; firedProjectile.velocity = Facing.FacingToUnitVector3(facing) * projectileVelocity; } }
private void StartMove() { Mode = AIMode.Move; //choose direction facing = Facing.RandomFacingThatIsntThisOne(facing); trajectory = Facing.FacingToUnitVector3(facing); //choose length of travel chosenTravelTime = Random.Range(minTravelTime, maxTravelTime); }
private void Move() { if (modeTime > chosenTravelTime) { StartFiring(); } Vector3 positionBefore = transform.position; base.MoveWithSliding(trajectory * Time.fixedDeltaTime * moveSpeed); Vector3 positionAfter = transform.position; if (positionBefore == positionAfter) { facing = Facing.OppositeFacing(facing); trajectory = Facing.FacingToUnitVector3(facing); } }