- Home /
Question by
Joseph Lerner · Aug 24, 2014 at 05:14 AM ·
c#animatorbooleanparameters
Can't Set Animator Boolean Parameter C#
I am trying to get the bool parameter named "Filling" to be true with this script. using UnityEngine; using System.Collections;
public class Scr : MonoBehaviour {
public Component anim;
void Start ()
{
anim = GetComponent<Animator>();
}
void Update ()
{
if(Input.GetButton("Fire1"))
anim.SetBool("Filling", true );
}
}
This gives me the following error message:
'UnityEngine.Component' does not contain a definition for 'SetBool' and no extension method 'SetBool' accepting a first argument of type 'UnityEngine.Component' could be found (are you missing a using directive or an assembly reference?) (CS1061) (Assembly-CSharp)
Here is the view in Unity.
I have been trying to figure out how to do this all day, my last post wasn't approved so I made this one more specific. Please help :(.
screenshot (1).png
(130.8 kB)
screenshot (3).png
(219.3 kB)
Comment
Best Answer
Answer by tanoshimi · Aug 24, 2014 at 06:12 AM
public Component anim;
should be
public Animator anim;