Page 417 - MDP2022-3
P. 417
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR;
using UnityEngine.XR.Interaction.Toolkit;
public class HeadLotate : MonoBehaviour
{
public GameObject enemy;
public GameObject controller;
public float speed;
// bool catch_Key1 = false;
public bool is_head_rotation_finish = false;
public static HeadLotate instance = null;
private void Awake()
{
if (instance == null) //instance가 null. 즉, 시스템상에 존재하고 있지 않을때
{
instance = this; //내자신을 instance로 넣어줍니다.
}
else
{
if (instance != this) //instance가 내가 아니라면 이미 instance가 하나 존재하고
있다는 의미
Destroy(this.gameObject); //둘 이상 존재하면 안되는 객체이니 방금
AWake된 자신을 삭제
}
}