Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class PlayerController : MonoBehaviour {
  6.  
  7. public float horizontal, vertical;
  8. Animator anim;
  9. public float divisorDeForca;
  10. private GameObject gameController;
  11.  
  12. void Awake(){
  13. anim = GetComponent<Animator> ();
  14. }
  15. // Use this for initialization
  16. void Start () {
  17. gameController = GameObject.Find ("GameController");
  18. }
  19. public void Animador(){
  20. horizontal = Input.GetAxis ("Horizontal");
  21. vertical = Input.GetAxis ("Vertical");
  22.  
  23. if (gameController.GetComponent<GameController> ().vidaJogador > 0) {
  24.  
  25. if(vertical > 0)
  26. anim.SetInteger ("estado", 1);
  27. else
  28. anim.SetInteger ("estado", 0);
  29. }
  30. }
  31. public void AdicionarForca(){
  32. horizontal = Input.GetAxis ("Horizontal") * 2;
  33. vertical = Input.GetAxis ("Vertical");
  34.  
  35. if (vertical > 0)
  36. transform.Translate (new Vector3(0,0,vertical / divisorDeForca));
  37. if (horizontal != 0)
  38. transform.Rotate (0,horizontal,0);
  39. }
  40. // Update is called once per frame
  41. void Update () {
  42. AdicionarForca ();
  43. Animador ();
  44. if (gameController.GetComponent<GameController> ().vidaJogador <= 0)
  45. anim.SetInteger ("estado",3);
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement