TeHArGiS10

Untitled

Jun 24th, 2016
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #pragma strict
  2.  
  3. var Enemy: Transform;
  4. var Player: Transform;
  5. var hit: RaycastHit;
  6. var hpText: GameObject;
  7. var hpINT: int = 100;
  8.  
  9. function Start () {
  10. hpText.GetComponent(UI.Text).text = "100";
  11. }
  12.  
  13. function Update () {
  14. if (Physics.Raycast(transform.position, -transform.forward, hit, 15)) {
  15. Enemy.transform.position = Vector3.MoveTowards(Enemy.position, Player.position, Time.deltaTime * 10);
  16. }
  17. if (Physics.Raycast(transform.position, -transform.forward, hit, 2)) {
  18. LoseHP();
  19. }
  20. if(hpINT == 0) {
  21. Destroy(Player.gameObject);
  22. }
  23. }
  24.  
  25. function LoseHP () {
  26. hpINT -= 0.003;
  27. hpText.GetComponent(UI.Text).text = hpINT.ToString();
  28. }
Advertisement
Add Comment
Please, Sign In to add comment