I’m trying to make a platformer using corgi engine.
and I’m making this boss fight level and I don’t want the player to run away from the enemy and just go to the next level. So the “gate to next level” gameobject is disabled by default. and I’m trying to enable it when the enemy is destroyed. But it doesn’t work. Here are all the pieces of code involved.
first, there’s the code I wrote and then corgi’s “Health” script…
using System.Collections;
using System.Collections.Generic;
using MoreMountains.CorgiEngine;
using UnityEngine;
public class EnableOnDeath : MonoBehaviour
{
[SerializeField] Health health;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if(health.died == true){
gameObject.SetActive(true);
}
}
}
using UnityEngine;
using System.Collections;
using MoreMountains.Tools;
using MoreMountains.Feedbacks;
namespace MoreMountains.CorgiEngine
{
.
.
.
public bool died = false;
.
.
.
public virtual void Kill()
{
died = true;
.
.
.
}
.
.
.
}
I actually tried doing it the other way around and making the gameobject enabled by default and doing setactive(false) when the enemy dies and it strangely works!!!