Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class seiya_walk : MonoBehaviour {
- public GameObject bar;
- public GameObject cursor;
- public bool inSkillBar;
- // Use this for initialization
- void Start () {
- }
- // Update is called once per frame
- void Update()
- {
- if (Input.GetKeyDown(KeyCode.S))
- {
- if (gameObject.GetComponent<Animator>().GetInteger("walk") == 1) { print(1); }
- gameObject.GetComponent<Animator>().SetInteger("walk", gameObject.GetComponent<Animator>().GetInteger("walk") == 1 ? 2 : 1);
- }
- if (Input.GetKeyDown(KeyCode.T))
- {
- inSkillBar = true;
- StartCoroutine(BarMove());
- }
- }
- IEnumerator BarMove()
- {
- bar.SetActive(true);
- cursor.SetActive(true);
- cursor.transform.position = new Vector3(bar.transform.position.x, bar.transform.position.y - 0.54f, 1f);
- Vector3 moveWhere = new Vector3(0f, 0.045f, 0f);
- while (inSkillBar)
- {
- yield return new WaitForSeconds(0.01f);
- cursor.transform.position += moveWhere;
- if(cursor.transform.localPosition.y >= 0.129f)
- {
- moveWhere = -moveWhere;
- }
- else if (cursor.transform.localPosition.y <= -0.179f)
- {
- moveWhere = -moveWhere;
- }
- if(moveWhere == new Vector3(0f, -0.1f, 0f)) { print("truth"); }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement