Skip to content
Permalink
399042d8ea
Go to file
 
 
Cannot retrieve contributors at this time
60 lines (43 sloc) 1.62 KB
using UnityEngine;
using System.Collections;
public class Enemy2 : MonoBehaviour {
public int health = 2;
public GameObject wheels;
public Vector3 enemyAngle = new Vector3(0, 270, 90);
public GameObject turret;
public GameObject bullet;
public Vector3 posCanon;
public float test;
public int testInt;
public GameObject newBullet;
public Vector3 playerPos;
public GameObject player;
void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.tag == "Bullet")
{
Destroy(gameObject);
}
}
void Update()
{
playerPos = new Vector3(player.transform.position.x, player.transform.position.y - 30, player.transform.position.z);
//Shooting ===================================================
posCanon = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y - 0.5f, gameObject.transform.position.z);
test = gameObject.transform.position.y;
testInt = Mathf.RoundToInt(test);
//shooting---------------------------------------------------------------------------------
if (testInt % 4 == 0)
{
newBullet = (GameObject)Instantiate(bullet, posCanon, transform.rotation);
iTween.MoveTo(newBullet, playerPos, 1);
}
//Health-----------------------------------------------------------------------------------
if (health == 0)
Destroy(gameObject);
if (health == 1)
Destroy(wheels);
if (transform.eulerAngles != enemyAngle)
transform.eulerAngles = enemyAngle;
}
}
You can’t perform that action at this time.