Hi!
I have a character with 2 animations. One is just an idle that will loop forever until I press the spacebar (I changed the tag to ‘Activate’). From there it will transition into a series of other animations.
I have set this up in the Animator window and I made a boolean parameter called ‘hitSpace’ to be used in a script.
This is the control script I wrote. I hooked it up to the character but it does nothing!
It doesn’t give any errors but it also doesn’t show anything in the console when I press space (maybe it doesn’t usually do that anyway?).
Can anyone help me?
using UnityEngine;
using System.Collections;
public class Alien_Behaviour : MonoBehaviour {
// Use this for initialization
private Animator anim;
private bool hitSpace;
void Start ()
{
anim = GetComponent<Animator>();
hitSpace = false;
}
// Update is called once per frame
void Update ()
{
if(Input.GetButtonDown("Activate"))
{
hitSpace = true;
anim.SetBool("hitSpace", hitSpace);
}
else
{
hitSpace = false;
anim.SetBool("hitSpace", hitSpace);
}
}
}