using System.Collections; using System.Collections.Generic; using UnityEngine; public class BipedTurretMissile : MonoBehaviour { public GameObject player; public int damage; public CameraController cc; public PlayerBlink pb; public float speed = 1; // Use this for initialization void Start() { player = GameObject.FindGameObjectWithTag("Player"); pb = player.GetComponent(); cc = GameObject.FindGameObjectWithTag("MainCamera").GetComponent(); } // Update is called once per frame void Update() { this.transform.position = new Vector2(Mathf.Lerp(this.transform.position.x, player.transform.position.x, speed * Time.deltaTime), Mathf.Lerp(this.transform.position.y, player.transform.position.y, speed * Time.deltaTime)); } private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.tag != "Player" && collision.gameObject.tag != "Enemy") { Destroy(this.gameObject); } else if (collision.gameObject.tag == "Player") { player.GetComponent().health -= damage; pb.isBlinking = true; Destroy(this.gameObject); cc.isShakcing = true; } if (collision.gameObject.tag == "Bullet" ) { Destroy(this.gameObject); } } }