Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- namespace SA
- {
- public class Helper : MonoBehaviour {
- [Range(0, 1)]
- public float vertical;
- public bool playAnim;
- public string[] oh_attacks;
- public string[] th_attacks;
- public bool twoHanded;
- public bool enableRM;
- public bool useItem;
- public bool interacting;
- Animator anim;
- void Start ()
- {
- anim = GetComponent<Animator>();
- }
- void Update ()
- {
- enableRM = !anim.GetBool("canMove");
- anim.applyRootMotion = enableRM;
- interacting = anim.GetBool("interacting");
- if (enableRM)
- return;
- if (useItem)
- {
- anim.Play("use_item");
- useItem = false;
- }
- anim.SetBool("two_handed", twoHanded);
- if(interacting)
- {
- playAnim = false;
- vertical = Mathf.Clamp(vertical, 0, 0.5f);
- }
- if(playAnim)
- {
- string targetAnim;
- if(!twoHanded)
- {
- int r = Random.Range(0, oh_attacks.Length);
- targetAnim = oh_attacks[r];
- }
- else
- {
- int r = Random.Range(0, th_attacks.Length);
- targetAnim = th_attacks[r];
- }
- vertical = 0;
- anim.CrossFade(targetAnim, 0.2f);
- //anim.SetBool("canMove",false);
- //enableRM = true;
- playAnim = false;
- }
- anim.SetFloat("vertical", vertical);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement