My Play Animation Script won’t accept The parameter from a function from my entity script.
I am trying to make it so an animation plays when a entity takes damage
All the damage is taken care of in two other scripts one an Entity script which has all the Entity stats like Health, Defense ect.
It also houses a void that receives damage values from foreign scripts like my sword script in the Int Parameter brackets which are referenced in the sword scripts and applied in the Entity script.
I cannot reference the Int parameter from the Play Animation Script to add to the update void.
_Damage won’t work like i want it to, i can’t really explain it because i’m not very literate in C#
the Error message is as follows:
Invalid token '=' in class, struct, or interface member declaration [Assembly-CSharp, Assembly-CSharp]
Invalid token ';' in class, struct, or interface member declaration [Assembly-CSharp, Assembly-CSharp]
The name '_Damage' does not exist in the current context [Assembly-CSharp]
The name 'damage' does not exist in the current context [Assembly-CSharp]
The name '_Damage' does not exist in the current context [Assembly-CSharp]
I don’t tell it very vividly so here is the Entire copy and pasted Script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AttackedAnimations : MonoBehaviour
{
public Animator anim;
//Damageable ForeignDamage;
damage = _Damage;
public void start()
{
_Damage = gameObject.GetComponent<Damageable>().TakeDamage(damage);
}
void Update()
{
if(GetComponent<Damageable>().TakeDamage(_Damage))
{
anim.Play("EnemyDamaged");
}
}
}