LoadNPC.cs 1.13 KB
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class LoadNPC : MonoBehaviour
{
    private GameObject mainCamera;
    public GameObject npcPrefab;
    int load_count = 0;

    public float distance;

    public Vector3 npc_look1;
    public Vector3 npc_look2;

    // Start is called before the first frame update
    public Vector3 position;

    bool npc1_destroy = false;

    void start()
    {
    }

    // Update is called once per frame
    void Update()
    {
        if (load_count < 2)
        {
            GameObject npc1 = Instantiate(npcPrefab, new Vector3(position.x - distance, position.y, position.z), new Quaternion(0, 0, 0, 0)) as GameObject;
            npc1.transform.LookAt(npc_look1);

            npc1.GetComponent<TargetEdited>().npc_no = 1;
            load_count++;

            GameObject npc2 = Instantiate(npcPrefab, new Vector3(position.x + distance, position.y, position.z), new Quaternion(0, 0, 0, 0)) as GameObject;
            npc2.transform.LookAt(npc_look2);
            npc2.GetComponent<TargetEdited>().npc_no = 2;

            load_count++;

        }
        

    }
}