Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class PlayerController : MonoBehaviour {
- public float horizontal, vertical;
- Animator anim;
- public float divisorDeForca;
- private GameObject gameController;
- void Awake(){
- anim = GetComponent<Animator> ();
- }
- // Use this for initialization
- void Start () {
- gameController = GameObject.Find ("GameController");
- }
- public void Animador(){
- horizontal = Input.GetAxis ("Horizontal");
- vertical = Input.GetAxis ("Vertical");
- if (gameController.GetComponent<GameController> ().vidaJogador > 0) {
- if(vertical > 0)
- anim.SetInteger ("estado", 1);
- else
- anim.SetInteger ("estado", 0);
- }
- }
- public void AdicionarForca(){
- horizontal = Input.GetAxis ("Horizontal") * 2;
- vertical = Input.GetAxis ("Vertical");
- if (vertical > 0)
- transform.Translate (new Vector3(0,0,vertical / divisorDeForca));
- if (horizontal != 0)
- transform.Rotate (0,horizontal,0);
- }
- // Update is called once per frame
- void Update () {
- AdicionarForca ();
- Animador ();
- if (gameController.GetComponent<GameController> ().vidaJogador <= 0)
- anim.SetInteger ("estado",3);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement