- Home /
The question is answered, right answer was accepted
Turning on and of animator? error CS0119: Expression denotes a `method group', where a `variable', `value' or `type' was expected
Hey guys trying to make a simple trigger to turn on the animator component. error CS0119: Expression denotes a method group', where a
variable', value' or
type' was expected
void OnTriggerEnter(Collider collision)
{
if (collision.gameObject.CompareTag ("Active")) {
GetComponent.Animator (true);
IsShooting += +1;
}
}
}
GetComponent.Animator (true);
doesn't mean anything.
Answer by cbjunior · Feb 11, 2016 at 08:06 AM
Your inner code is incorrect, syntactically speaking. You are calling the method GetComponent<>()
as if it were a field. In the second line, you should remove the second plus sign. In C#, positive values don't need to be specified, only negatives. It should be the following:
GetComponent<Animator>().enabled = true;
IsShooting += 1;
Answer by ReeCocho · Feb 10, 2016 at 05:40 PM
Change "GetComponent.Animator..."
to
GetComponent().enabled = true;
Think your answer was decimated due to not applying formatting.
Answer by Jessespike · Feb 10, 2016 at 06:11 PM
GetComponent<Animator>().enabled = true;
http://docs.unity3d.com/ScriptReference/GameObject.GetComponent.html