Newer
Older
HardPoint-Project-Abertay-University-Unity3D / Assets / FlyEnemyScript.cs
@Rackday Rackday on 18 Aug 2024 824 bytes Project Added
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Animations;

public class FlyEnemyScript : MonoBehaviour, IUpdatable
{
    int i = 0;
    GameObject player;
    private void Start()
    {
        player = GameObject.Find("Player");
    }

    // Update is called once per frame

    void IUpdatable.Updating()
    {
        if(player != null)
        transform.LookAt(player.transform.position);
        if (i == 0)
        {
            BoxCollider b = GetComponent<BoxCollider>();
            FlyEnemyScript[] flyEnemyScripts = GameObject.FindObjectsOfType<FlyEnemyScript>();
            foreach (FlyEnemyScript f in flyEnemyScripts)
            {

                Physics.IgnoreCollision(f.GetComponent<BoxCollider>(), b);
            }
            i++;
        }
    }
}