Unityでジャンクゲームを作っているっぽい

会社帰りにGPD PocketにUnity入れてゲーム作ってます

【CEtest2】21_CorgiEngineでBOSSを倒してタイトル画面に移動したい

いろいろ試した結果、スクリプト書いて解決した

ボスオブジェクトにTagを設定

f:id:mekatamatama:20220315205812p:plain

スクリプトを書く

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.CorgiEngine;	//これでHealthコンポーネントにアクセスできた
using MoreMountains.Tools;		//念のため追加

public class test_boss : MonoBehaviour{
	GameObject boss;		//検索したオブジェクト入れる用

	void Start(){
		boss = GameObject.FindWithTag("Boss");	//ボスを検索
	}

	void Update(){
		Health health = boss.GetComponent<Health>();	//ボスのHealthコンポーネント取得
		//ボスの死亡判定
		if(health.CurrentHealth <= 0){
			MMSceneLoadingManager.LoadScene("title");	//タイトル画面に遷移
		}
	}
}

スクリプトアサイ

とりあえずLevelManagerの子供に空のオブジェクトを用意
LevelMyScriptとでも名前変更
ここにスクリプトアサイ
f:id:mekatamatama:20220315205904p:plain

ゲームのループできた~
youtu.be