Skip to content
Permalink
6e157e73d6
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
47 lines (34 sloc) 1.22 KB
using UnityEngine;
using System.Collections;
public class Enemy1 : MonoBehaviour {
public int health = 1;
public Vector3 enemyAngle = new Vector3(0, 90, 270);
public float test;
//shooting -----------------------
public GameObject turret;
public GameObject bullet;
public Vector3 posCanon;
public GameObject newBullet;
void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.tag == "Bullet")
{
Destroy(gameObject);
}
}
void Update()
{
test = gameObject.transform.position.y;
//shooting---------------------------------------------------------------------------------
posCanon = new Vector3(turret.transform.position.x, turret.transform.position.y - 0.5f, turret.transform.position.z);
if (test % 2 == 0)
{
newBullet = (GameObject)Instantiate(bullet, posCanon, transform.rotation);
iTween.MoveTo(posCanon, new Vector3(posCanon.transform.position.x, posCanon.transform.position.y - 20, 5), 1);
}
if (health == 0)
Destroy(gameObject);
if (transform.eulerAngles != enemyAngle)
transform.eulerAngles = enemyAngle;
}
}