Advertisement
Guest User

Untitled

a guest
Nov 25th, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class character : MonoBehaviour {
  5. #region zycie
  6. public static float health = 5;
  7. public static bool death = false;
  8. private static int blood = 1;
  9. #endregion
  10.  
  11. // Use this for initialization
  12. void Start () {
  13.  
  14.  
  15. }
  16.  
  17. // Update is called once per frame
  18. void Update () {
  19. hit();
  20.  
  21.  
  22.  
  23. }
  24. void dealdamage()
  25. {
  26. health--;
  27. }
  28.  
  29. void hit()
  30. {
  31. Debug.DrawLine (transform.position, hit.point, Color.cyan);
  32.  
  33. // do a raycast in the gun forward direction:
  34. if (Physics.Raycast(transform.position, transform.forward, hit)
  35. {
  36. // if something is hit, check whether it's tagged "zombie":
  37. if(hit.gameObject.CompareTag("human"))
  38. { // if so, apply damage to it
  39. hit.collider.SendMessageUpwards ("dealdamage", SendMessageOptions.DontRequireReceiver);
  40. }
  41. }
  42. }
  43.  
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement