Skip to content
Permalink
399042d8ea
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
49 lines (36 sloc) 1.28 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;
public int testInt;
//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;
testInt = Mathf.RoundToInt(test);
//shooting---------------------------------------------------------------------------------
posCanon = new Vector3(turret.transform.position.x, turret.transform.position.y - 0.5f, turret.transform.position.z);
if (testInt % 4 == 0)
{
newBullet = (GameObject)Instantiate(bullet, posCanon, transform.rotation);
iTween.MoveTo(newBullet, new Vector3(newBullet.transform.position.x, newBullet.transform.position.y - 40, 5), 1);
}
if (health == 0)
Destroy(gameObject);
if (transform.eulerAngles != enemyAngle)
transform.eulerAngles = enemyAngle;
}
}