Advertisement
Guest User

man_controller

a guest
Nov 29th, 2017
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Controlador_hombre : MonoBehaviour {
  6.  
  7. public Animator my_animator;
  8.  
  9. public List<Controlador_puntos> puntos;
  10. public Controlador_puntos mi_punto;
  11. public Controlador_puntos punto_inicio;
  12.  
  13. public int indice = 0;
  14.  
  15. public bool se_mueve = true;
  16.  
  17. private bool cayendo = false;
  18. private bool caido = false;
  19. private bool muerto = false;
  20.  
  21. private float angulo_caida = 85;
  22. private float velocidad = 5;
  23. private bool look_already = false;
  24.  
  25. // Use this for initialization
  26. void Start () {
  27. mi_punto = puntos[0];
  28. if (se_mueve)
  29. {
  30. transform.position = punto_inicio.transform.position;
  31.  
  32. my_animator.SetBool("Move", true);
  33. }
  34. else {
  35. my_animator.SetBool("Move", false);
  36. }
  37. }
  38.  
  39.  
  40.  
  41. public void siguiente_punto() {
  42.  
  43.  
  44. indice++;
  45. mi_punto.arrived = false;
  46. if (indice == puntos.Count)
  47. {
  48. Debug.Log("REINICIANDO " + indice);
  49. indice = 0;
  50. }
  51. mi_punto = puntos[indice];
  52. Debug.Log(mi_punto);
  53.  
  54. Debug.Log(indice);
  55. }
  56.  
  57.  
  58. // Update is called once per frame
  59. void Update () {
  60.  
  61. if (!muerto && se_mueve)
  62. {
  63. Debug.Log("andando");
  64.  
  65. if (!mi_punto.arrived)
  66. {
  67. if (!look_already) {
  68. transform.LookAt(mi_punto.transform);
  69. look_already = true;
  70. }
  71. }
  72. else
  73. {
  74. look_already = false;
  75. siguiente_punto();
  76. }
  77.  
  78. }
  79.  
  80. if(cayendo && !caido){
  81.  
  82. Debug.Log("no ha caido todavia");
  83. float angulo_x = transform.rotation.eulerAngles.x;
  84. if (angulo_x <= angulo_caida)
  85. {
  86. Debug.Log("el angulo es : " + angulo_x);
  87. transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles.x + velocidad ,
  88. transform.rotation.eulerAngles.y, transform.rotation.eulerAngles.z);
  89. Debug.Log(transform.rotation);
  90. }
  91. else{
  92. caido = true;
  93. cayendo = false;
  94. Debug.Log("ha caido aparentemente");
  95. }
  96. }
  97.  
  98.  
  99. }
  100.  
  101. void OnCollisionEnter(Collision collision)
  102. {
  103. GameObject objeto = collision.gameObject;
  104.  
  105. Puntal mi_puntal = objeto.GetComponent<Puntal>();
  106.  
  107. if (mi_puntal != null)
  108. {
  109. caer();
  110. }
  111. }
  112.  
  113.  
  114. public void caer()
  115. {
  116. my_animator.Stop();
  117. muerto = true;
  118. cayendo = true;
  119. }
  120.  
  121.  
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement