Guest User

Untitled

a guest
Feb 17th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5.  
  6. public class Unit : MonoBehaviour
  7. {
  8. public Material matGhostGreen;
  9. public Material matGhostRed;
  10. public Material matNormal;
  11.  
  12.  
  13.  
  14. string tagCreate = "CreateUnit";
  15. string tagComplete = "CompleteUnit";
  16. public bool sBefore = false;
  17.  
  18. public BoxCollider bc1;
  19. public BoxCollider bc2;
  20. void Start()
  21. {
  22. GlobalVar.onTriggerUnit = true;
  23. }
  24.  
  25. void Update()
  26. {
  27. Debug.Log("!!!!!!");
  28. if (gameObject.tag == tagCreate)
  29. {
  30. if ( GlobalVar.onTriggerUnit==false)
  31. {
  32. gameObject.GetComponentInChildren<MeshRenderer>().material = matGhostGreen;
  33. }
  34. if(GlobalVar.onTriggerUnit == true)
  35. {
  36.  
  37. gameObject.GetComponentInChildren<MeshRenderer>().material = matGhostRed;
  38. }
  39.  
  40. }
  41.  
  42.  
  43.  
  44. /* if ((gameObject.tag == tagCreate) && (GlobalVar.onTriggerUnit == true))
  45. {
  46.  
  47.  
  48. gameObject.GetComponentInChildren<MeshRenderer>().material = GhostNone;
  49.  
  50.  
  51.  
  52. }*/
  53.  
  54. if (GlobalVar.activeCreateUnit == false)
  55. {
  56. gameObject.GetComponentInChildren<MeshRenderer>().material = matNormal;
  57.  
  58.  
  59. gameObject.tag = tagComplete;
  60. bc1.enabled = true;
  61. bc2.enabled = false;
  62. Destroy(gameObject.GetComponent<Rigidbody>());
  63. }
  64. }
  65. void OnTriggerEnter()
  66. {
  67. GlobalVar.onTriggerUnit = true;
  68. }
  69.  
  70. void OnTriggerExit()
  71. {
  72. GlobalVar.onTriggerUnit = false;
  73. }
  74.  
  75. void OnTriggerStay(Collider other)
  76. {
  77. Debug.Log("dfgdgdfg");
  78. // if (other.attachedRigidbody)
  79. // {
  80. // other.attachedRigidbody.AddForce(Vector3.up * 10);
  81. //}
  82. }
Add Comment
Please, Sign In to add comment