Hello, I am trying to decrease the health of my player when I run the animation from my enemy. I first create the player gamobject:
public GameObject player;
Then I find the player as my enemy is a prefab:
private void Start()
{
player = GameObject.Find(“Player”);
Finally I reference the Player_health (public int) where my enemy hits him and I get a error:
if (Vector3.Distance(transform.position, Target_list[0].transform.position) < hit_range)
{
// hit
agent.speed = 0;
ani.SetInteger(“corp”, 2);
ani.SetInteger(“legs”, 0);
in_hitting = true;
in_walk = false;
hit_ready = true;
//code to reference Player_health from another script
player.Player_health = player.Player_health - 15;
}
Probably a simple answer, I apologize I haven’t used C# in years. Thanks!