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 Controlador_hombre : MonoBehaviour {
- public Animator my_animator;
- public List<Controlador_puntos> puntos;
- public Controlador_puntos mi_punto;
- public Controlador_puntos punto_inicio;
- public int indice = 0;
- public bool se_mueve = true;
- private bool cayendo = false;
- private bool caido = false;
- private bool muerto = false;
- private float angulo_caida = 85;
- private float velocidad = 5;
- private bool look_already = false;
- // Use this for initialization
- void Start () {
- mi_punto = puntos[0];
- if (se_mueve)
- {
- transform.position = punto_inicio.transform.position;
- my_animator.SetBool("Move", true);
- }
- else {
- my_animator.SetBool("Move", false);
- }
- }
- public void siguiente_punto() {
- indice++;
- mi_punto.arrived = false;
- if (indice == puntos.Count)
- {
- Debug.Log("REINICIANDO " + indice);
- indice = 0;
- }
- mi_punto = puntos[indice];
- Debug.Log(mi_punto);
- Debug.Log(indice);
- }
- // Update is called once per frame
- void Update () {
- if (!muerto && se_mueve)
- {
- Debug.Log("andando");
- if (!mi_punto.arrived)
- {
- if (!look_already) {
- transform.LookAt(mi_punto.transform);
- look_already = true;
- }
- }
- else
- {
- look_already = false;
- siguiente_punto();
- }
- }
- if(cayendo && !caido){
- Debug.Log("no ha caido todavia");
- float angulo_x = transform.rotation.eulerAngles.x;
- if (angulo_x <= angulo_caida)
- {
- Debug.Log("el angulo es : " + angulo_x);
- transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles.x + velocidad ,
- transform.rotation.eulerAngles.y, transform.rotation.eulerAngles.z);
- Debug.Log(transform.rotation);
- }
- else{
- caido = true;
- cayendo = false;
- Debug.Log("ha caido aparentemente");
- }
- }
- }
- void OnCollisionEnter(Collision collision)
- {
- GameObject objeto = collision.gameObject;
- Puntal mi_puntal = objeto.GetComponent<Puntal>();
- if (mi_puntal != null)
- {
- caer();
- }
- }
- public void caer()
- {
- my_animator.Stop();
- muerto = true;
- cayendo = true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement