Skip to content

Instantly share code, notes, and snippets.

@sabotai
Created April 26, 2017 20:59
Show Gist options
  • Save sabotai/b95a9863864a1b5985c8106249954086 to your computer and use it in GitHub Desktop.
Save sabotai/b95a9863864a1b5985c8106249954086 to your computer and use it in GitHub Desktop.
Minimal Animator Control Script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BasicControl : MonoBehaviour {
Animator myAnim;
int current;
// Use this for initialization
void Start () {
//assign the animator that's already attached to the same game object as the script
myAnim = GetComponent<Animator>();
current = 0;
}
// Update is called once per frame
void Update () {
if ( Input.GetKey (KeyCode.W)) {
current = 1;
} else {
current = 0;
}
//use the SetInteger function to update the animation parameter
//"WhichState" is the name of the parameter and current is the value it's being updated to
myAnim.SetInteger("WhichState", current);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment