using System.Collections.Generic;
using UnityEngine;
public class Animchange : MonoBehaviour
{
[SerializeField] Health Health;
Animator m_Animator;
// Start is called before the first frame update
void Start()
{
m_Animator = gameObject.GetComponent<Animator>();
}
public int Health
{
get { return _Health; }
set
{
_Health = value;
if (_Health == 1)
{
m_Animator.SetBool("animbool", true);
}
}
}
// Update is called once per frame
void Update()
{
}
}```
#Getting an int I mentioned before
1 messages · Page 1 of 1 (latest)
I am trying to change the parameter if my health variable form another script changes but there is a problem with public int Health what shoudl I use instead?
What is the problem with it
The type 'Animchange' already contains a definition for 'Health'
You cannot have two variables with the same name
I get Health from Health script
It creates a new
I want to use the one I mentioned before
I have no idea when you have "mentioned" this before
[SerializeField] Health Health;
This is the first time I am seeing this problem. We are not a hivemind on this server. If you explained things to someone else you will have to explain them again
I am trying to check if Health variable from Health script changed not to create another one
So, if you're checking if a variable in the Health script has changed, why are you checking it in a different script
Check it in Health
So?
I am trying to change the childs animator parameter
Honestly why does this script even exist at all
is there another way?
This all seems like something Health should do