Search Unity

Run three different animations at the same time for character

Discussion in 'Animation' started by DiluteFlea, Aug 18, 2019.

  1. DiluteFlea

    DiluteFlea

    Joined:
    Jul 19, 2019
    Posts:
    1
    Hi,
    I am a fairly new user to Unity. I am developing a proof of concept for a potential fan game. I have a character that has 3 different animations when he runs, there are animations for the head, torso, and the legs. I tried combining the animations into a single .fbx file but the result proved insanely buggy. I've been messing around with Avatar Masks for the different parts of the body. If you want, here is my movement script:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. public class Movement : MonoBehaviour {
    5.     public float movementSpeed;
    6.     public float movementSpeed1;
    7.     public float RotationSpeed;
    8.     public float RotationSpeed2;
    9.    
    10.     Animator anim;
    11.     // Use this for initialization
    12.     void Start () {
    13.    
    14.     anim = GetComponent<Animator>();
    15.    
    16.     }
    17.     //Update is called once per frame
    18.     void FixedUpdate () {
    19.         if (Input.GetKey (KeyCode.LeftShift) && Input.GetKey ("s")) {
    20.             transform.position += transform.TransformDirection (Vector3.forward) * Time.deltaTime * movementSpeed * 2.5f;
    21.         }   else if (Input.GetKey ("s") && !Input.GetKey (KeyCode.LeftShift)) {
    22.             transform.position += transform.TransformDirection (Vector3.forward) * Time.deltaTime * movementSpeed1;
    23.         }   else if (Input.GetKey ("w")) {
    24.             transform.position -= transform.TransformDirection (Vector3.forward) * Time.deltaTime * movementSpeed;
    25.         }
    26.  
    27.         if (Input.GetKey (KeyCode.LeftShift) && Input.GetKey ("a")) {
    28.             transform.Rotate(Vector3.up * RotationSpeed * Time.deltaTime);
    29.         }   else if (Input.GetKey ("d") && !Input.GetKey (KeyCode.LeftShift)) {
    30.             transform.Rotate(Vector3.up * RotationSpeed2 * Time.deltaTime);
    31.         }   else if (Input.GetKey ("a")) {
    32.             transform.Rotate(Vector3.up * RotationSpeed * Time.deltaTime);
    33.         }
    34.          
    35.         }
    36. }
    37.  
    I attached animations to the Avatar Mask layers, but no animation played. Any help would be appreciated.