Created
April 26, 2017 20:59
-
-
Save sabotai/b95a9863864a1b5985c8106249954086 to your computer and use it in GitHub Desktop.
Minimal Animator Control Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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