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
41 lines (29 sloc) 997 Bytes
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;
void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.tag == "Bullet")
{
health = health - 1;
}
}
void Update()
{
//Shooting ===================================================
posCanon = new Vector3(turret.transform.position.x, turret.transform.position.y - 0.5f, turret.transform.position.z);
//Health-----------------------------------------------------------------------------------
if (health == 0)
Destroy(gameObject);
if (health == 1)
Destroy(wheels);
if (transform.eulerAngles != enemyAngle)
transform.eulerAngles = enemyAngle;
}
}