Search Unity

How to make it where if objects don't collide your character dies?

Discussion in 'Editor & General Support' started by JSwaggerex, Jan 13, 2019.

  1. JSwaggerex

    JSwaggerex

    Joined:
    Jan 13, 2019
    Posts:
    1
    I am pretty new to coding and programming so I am having an issue with figuring out just what should I put in this script so that if my character does not collect something they will die. Below is the coding I have for it but the "else" section of it is marked red from "anim.SetTrigger("Collected") = false;". Please help me find just what the right coding should be.

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class Baby : MonoBehaviour
    {
    private Animator anim;

    public bool GameObject { get; private set; }

    private void Start()
    {
    anim = GetComponent<Animator>();

    }


    private void OnTriggerEnter(Collider other)
    {
    if (other.tag == "Character")
    {
    GameManager.Instance.GetBaby();
    anim.SetTrigger("Collected");
    Destroy(gameObject, 1.5f);
    }
    else

    {
    anim.SetTrigger("Collected") = false;
    anim.SetTrigger("Death");


    }
    }
    }