Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Unit : MonoBehaviour
- {
- public Material matGhostGreen;
- public Material matGhostRed;
- public Material matNormal;
- string tagCreate = "CreateUnit";
- string tagComplete = "CompleteUnit";
- public bool sBefore = false;
- public BoxCollider bc1;
- public BoxCollider bc2;
- void Start()
- {
- GlobalVar.onTriggerUnit = true;
- }
- void Update()
- {
- Debug.Log("!!!!!!");
- if (gameObject.tag == tagCreate)
- {
- if ( GlobalVar.onTriggerUnit==false)
- {
- gameObject.GetComponentInChildren<MeshRenderer>().material = matGhostGreen;
- }
- if(GlobalVar.onTriggerUnit == true)
- {
- gameObject.GetComponentInChildren<MeshRenderer>().material = matGhostRed;
- }
- }
- /* if ((gameObject.tag == tagCreate) && (GlobalVar.onTriggerUnit == true))
- {
- gameObject.GetComponentInChildren<MeshRenderer>().material = GhostNone;
- }*/
- if (GlobalVar.activeCreateUnit == false)
- {
- gameObject.GetComponentInChildren<MeshRenderer>().material = matNormal;
- gameObject.tag = tagComplete;
- bc1.enabled = true;
- bc2.enabled = false;
- Destroy(gameObject.GetComponent<Rigidbody>());
- }
- }
- void OnTriggerEnter()
- {
- GlobalVar.onTriggerUnit = true;
- }
- void OnTriggerExit()
- {
- GlobalVar.onTriggerUnit = false;
- }
- void OnTriggerStay(Collider other)
- {
- Debug.Log("dfgdgdfg");
- // if (other.attachedRigidbody)
- // {
- // other.attachedRigidbody.AddForce(Vector3.up * 10);
- //}
- }
Add Comment
Please, Sign In to add comment