- Home /
 
 
               Question by 
               Edward-M-Ortiz · Aug 22, 2016 at 05:08 AM · 
                animationtriggerskeypress  
              
 
              How do you run an animation for a character by pressing a Key with C#?
So far I have made the animations and created triggers to accommodate the animations for hitting and running. The animation I am trying to run is called PlayerHit-1 And the key I am trying to make call the trigger is w
This is my code so far
using UnityEngine; using System.Collections;
public class Player : MonoBehaviour { private Animator animator;
 // Use this for initialization
 void Start () 
 {
     animator = GetComponent<Animator>();
 }
 
 // Update is called once per frame
 void Update () {
     if(Input.getKeyDown("w"))
     {
         animator.SetTrigger("PlayerHit-1");
     }
 }
 
               }
Please help, I am a noob..
               Comment
              
 
               
              Your answer