- Home /
Missing component exception in unity. there is no animation component attached but a script is trying to access it.
However, i have made not references t this component in my script. all i try to do is edit an animator float.
this is my script:
#pragma strict
internal var animator : Animator;
var dead : float;
var Health = 100;
animator = GetComponent(Animator); //assigns Animator component when we start the game
function Start () {
animator = GetComponent(Animator); //assigns Animator component when we start the game
}
function Update ()
{
if (Health<=0)
{
dead = 0.2;
}
else
{
dead = 0.0;
}
}
function ApplyDamage (DamageAmount : int)
{
Health -= DamageAmount;
}
/*function Dead()
{
Destroy (gameObject);
*/
function FixedUpdate ()
{
animator.SetFloat ("Dead",dead);
}
and this is the error:
MissingComponentException: There is no 'Animation' attached to the "vincent" game object, but a script is trying to access it. You probably need to add a Animation to the game object "vincent". Or your script needs to check if the component is attached before using it. UnityEngine.Animation.Play (System.String animation) (at C:/BuildAgent/work/d63dfc6385190b60/artifacts/EditorGenerated/Animations.cs:569) Damage Reciever.Update () (at Assets/Damage Reciever.js:19)
Thanks in advance.
Edit: I DO have an Animator component, but it is commenting on the Animation component which i make no references to in my script.
Edit2:
Answer by Jeff-Kesselman · Nov 18, 2014 at 04:56 PM
The problem is exactly what it says it is.
animator.SetFloat ("Dead",dead);
This tries to set a field on the animator component, but you have none on the object.
But i do have an animator component, just not an animation component
Your answer
![](https://koobas.hobune.stream/wayback/20220613171837im_/https://answers.unity.com/themes/thub/images/avi.jpg)