実現したいこと。
メソッド内で数秒後にSceneManager.LoadSceneを使いたいです。
エラー
スクリプトのエラーはありませんがInvokeが機能してないように思います。
スクリプト
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class UFO : MonoBehaviour
{
GameManager gameManager; private float timeElapsed = 0; public float timeOut = 7; private const int Maxhp = 5; public int hp; private void Awake() { } // Use this for initialization void Start() { } // Update is called once per frame void Update() { timeElapsed += Time.deltaTime; if (timeElapsed >= timeOut) { Invoke("Faile", 1.0f); } } // ぶつかった瞬間に呼び出される void OnTriggerEnter2D(Collider2D c) { // ヒットポイントが0以下であれば if (hp <= 0) { Invoke("Scene", 2.0f); } } void Scene() { SceneManager.LoadScene("MainSuccess"); } void Faile() { SceneManager.LoadScene("MainFaile"); }
}
あなたの回答
tips
プレビュー