Tuesday, April 16, 2024
HomeSample Page

Sample Page Title


My character dying animation works and when the character lies on the bottom, textual content seems saying “Wasted”. I added an object and it respawns.

The primary downside is that though he respawns, the character nonetheless performs the demise animation on the bottom after respawning within the new location, as proven within the animation under:

enter image description here

utilizing UnityEngine;
utilizing DG.Tweening;
utilizing UnityEngine.UI;
utilizing UnityEngine.SceneManagement;

public class Health : MonoBehaviour {

 public float curHealth;
 public float maxHealth;
 public bool enemyDied = false;
 personal Animator anim;
 public Slider healthBar;
 personal ThirdPersonCharacter thirdPerson;
 personal void Start()
 {
     curHealth = maxHealth;
     healthBar.minValue = 0;
     healthBar.worth = curHealth;
     healthBar.maxValue = maxHealth;
     anim = GetComponent<Animator>();
     thirdPerson = GetComponent<ThirdPersonCharacter>();
 }
 void Update()
 {
     float hit = anim.GetFloat("hit");
     if (hit > 0)
     {
         hit -= Time.deltaTime * 3;
         anim.SetFloat("hit", hit);
     }
     if (curHealth < 1)
     {
         Physics.SyncTransforms();
         anim.SetBool("demise", true);
     }
     if (Input.GetKeyUp(KeyCode.Space))
     {
         SendDamage(Random.Range(10, 20));
     }
 }
 public void SendDamage(float damageValue)
 {
     curHealth -= damageValue;
     healthBar.worth = curHealth;
     if (curHealth <= 0)
     {
         enemyDied = true;
     }
     Invoke(nameof(Resurrect), 2f);
     anim.SetFloat("hit", 1);
 }
 public void Resurrect()
 {
     SpriteRenderer blackout = Camera.primary.remodel.GetComponentInChildren<SpriteRenderer>();
     Color orjinalRenkWasted = blackout.colour;
     Color clrWhitealpha0 = new Color(1, 1, 1, 1);
     Color clr = new Color(0, 0, 0, 1);
     blackout.remodel.GetChild(0).GetComponent<SpriteRenderer>().DOColor(clr, .5f).SetDelay(2f).OnStart(() =>
     {
         blackout.DOColor(clrWhitealpha0, .5f).SetDelay(.5f).OnComplete(() =>
         {
             Invoke(nameof(BringEverythingBack), 2f);
             blackout.remodel.GetChild(0).GetComponent<SpriteRenderer>().DOColor(new Color(0, 0, 0, 0), .5f).SetDelay(2.5f).OnStart(() =>
             {
                 blackout.DOColor(orjinalRenkWasted, .25f);
             });
         });
     });
 }

 void BringEverythingBack()
 {
     remodel.root.place = GameObject.FindGameObjectWithTag("Respawn").remodel.place;
 }

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments