Guest User

Untitled

a guest
Feb 17th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 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==true)
  31. {
  32. gameObject.GetComponentInChildren<MeshRenderer>().material = matGhostGreen;
  33. }
  34. else
  35. {
  36. gameObject.GetComponentInChildren<MeshRenderer>().material = matGhostRed;
  37. }
  38.  
  39. }
  40.  
  41.  
  42. /* if ((gameObject.tag == tagCreate) && (GlobalVar.onTriggerUnit == true))
  43. {
  44.  
  45.  
  46. gameObject.GetComponentInChildren<MeshRenderer>().material = GhostNone;
  47.  
  48.  
  49.  
  50. }*/
  51.  
  52. if (GlobalVar.activeCreateUnit == false)
  53. {
  54. gameObject.GetComponentInChildren<MeshRenderer>().material = matNormal;
  55.  
  56.  
  57. gameObject.tag = tagComplete;
  58. bc1.enabled = true;
  59. bc2.enabled = false;
  60. Destroy(gameObject.GetComponent<Rigidbody>());
  61. }
  62. }
  63. void OnTriggerEnter()
  64. {
  65. GlobalVar.onTriggerUnit = true;
  66. }
  67.  
  68. void OnTriggerExit()
  69. {
  70. GlobalVar.onTriggerUnit = false;
  71. }
  72.  
  73. void OnTriggerStay(Collider other)
  74. {
  75. Debug.Log("dfgdgdfg");
  76. // if (other.attachedRigidbody)
  77. // {
  78. // other.attachedRigidbody.AddForce(Vector3.up * 10);
  79. //}
  80. }
Add Comment
Please, Sign In to add comment