Search Unity

Setting up an animator

Discussion in 'Scripting' started by PvTGreg, Jul 22, 2014.

  1. PvTGreg

    PvTGreg

    Joined:
    Jan 29, 2014
    Posts:
    365
    Hi i was wandering if you guys could help me set up my characters animatior using blendtrees at the moment im just using bools to switch between animations but it is to clunky and looks bad, i just need help understanding what to do



    //this is the script that i am using to change between them
    using UnityEngine;
    using System.Collections;

    public class amiwalking : MonoBehaviour {
    Animator anim;
    PlayerMovement Variables;
    public GameObject Revolver;
    void Start ()
    {
    GameObject Player = GameObject.Find("PlayerController(Clone)");
    anim = GetComponentInChildren<Animator>();
    }

    //Update is called once per frame
    void Update ()
    {
    //////MOVEMENT
    if (Input.GetButtonDown ("Vertical")) {
    anim.SetBool ("Walking", true);
    }

    if (Input.GetButtonUp ("Vertical")) {
    anim.SetBool ("Walking", false);
    }

    if (Input.GetButtonDown ("Horizontal")) {
    anim.SetBool ("WalkingSide", true);
    }

    if (Input.GetButtonUp ("Horizontal")) {
    anim.SetBool ("WalkingSide", false);
    }

    if (Input.GetButtonDown ("Run")) {
    anim.SetBool ("Running", true);
    }

    if (Input.GetButtonUp ("Run")) {
    anim.SetBool ("Running", false);
    }


    if (Variables.grounded == false) {
    anim.SetBool ("Jumping", true);
    }
    if (Variables.grounded == true) {
    anim.SetBool ("Jumping", false);
    }



    if (Input.GetButtonDown ("Crouch"))
    {
    anim.SetBool ("Crouch", true);
    }

    if (Input.GetButtonUp ("Crouch"))
    {
    anim.SetBool ("Crouch", false);
    }
    /////MOVEMENT






    }



    }
     

    Attached Files:

  2. PvTGreg

    PvTGreg

    Joined:
    Jan 29, 2014
    Posts:
    365
    oh and im using the character controller with the fps walker enhanced script
     
  3. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
  4. PvTGreg

    PvTGreg

    Joined:
    Jan 29, 2014
    Posts:
    365
  5. PvTGreg

    PvTGreg

    Joined:
    Jan 29, 2014
    Posts:
    365