トマシープが学ぶ

Unity/VR好きのミーハー初心者 記事内容は自分用のメモ。何も求めないで

自分用はてな記法スクリプト

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class atari : MonoBehaviour
{
    SpriteRenderer MainSpriteRenderer;
    public GameObject player;
    public GameObject wifi;
    public Text point_text;
    public Sprite genki;
    public Sprite turai;
    public AudioSource wifion;
    public AudioSource wifinasi;

    float point = 0.0f;
    // Start is called before the first frame update
    void Start()
    {
        MainSpriteRenderer = player.GetComponent<SpriteRenderer>();
    }

    // Update is called once per frame
    void Update()
    {
        Vector3 Apos = player.transform.position;
        Vector3 Bpos = wifi.transform.position;
        float dis = Vector3.Distance(Apos, Bpos);
        if (dis < 2.0f)
        {
            Debug.Log("近づいた");
            wifion.Pause();
            wifinasi.UnPause();
            point =point+(8-dis)*Time.deltaTime;
            int poi = (int)point;
            point_text.text= "元気"+point.ToString("f0") +"%";
            MainSpriteRenderer.sprite =genki;
        }
        else
        {
            wifion.UnPause();
            wifinasi.Pause();
            MainSpriteRenderer.sprite = turai;
        }

        if (point > 100)
        {
            Debug.Log("クリア");
            SceneManager.LoadScene("ED");
        }
    }
}