- Home /
how to disable animator after load in from checkpoint
So for some context, I made a healthbar that loads in after 52 seconds (waits 52 seconds and then goes from 0 health to 100 health) and now I made checkpoints as well. Both work fine seperately but when I die, the healthbar animation resets and I have to wait 52 seconds for the healthbar to be visible. I tried disabling the animator when you die and respawn at a checkpoint but that doesn't work as it is overriden by my health bar script. This is my healthbar script:
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
 
 public class Healthbar : MonoBehaviour
 {
     [SerializeField] private Slider slider;
     
     [SerializeField] private Animator anim;
     private float Waittime = 52f;
    
     public GameObject player;
 
     public void SetMaxHealth(int health)
     {
         slider.maxValue = health;
         slider.value = health;
     }
     public void SetHealth(int health)
     {
         slider.value = health;
     }
 
     private void Update()
     {
            
         
 
         if (Waittime <= 0)
         {
             anim.enabled = false;
            
         }
         else
         {
             Waittime -= Time.deltaTime;
             anim.enabled = true;
         }
     }
 
     
 }
This is my attempt at disabling the animator after the player respawns from a checkpoint (it might help):
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class healthafter : MonoBehaviour
 {
     // Start is called before the first frame update
     private GameMaster GM;
     public Animator anim;
 
     void Start()
     {
         GM = GameObject.FindGameObjectWithTag("GM").GetComponent<GameMaster>();
         transform.position = GM.lastCheckpointPos;
         anim.enabled = false;
     }
  }
how do I disable the animation after the player respawns from a checkpoint?
Your answer
 
 
             Follow this Question
Related Questions
2D Animation does not start 1 Answer
i need help with my respawn script 1 Answer
How would one make a Health Bar decrease if a player is in a specific animation state? 1 Answer
Playing two animations simultaneously that both alter the same sprite image? 1 Answer
Trying to make an animation delay between each loop 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                