Advertisement
Guest User

Untitled

a guest
Nov 25th, 2014
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 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. RaycastHit hit;
  32.  
  33. Debug.DrawLine (transform.position, transform.forward, Color.cyan);
  34.  
  35. // do a raycast in the gun forward direction:
  36. if (Physics.Raycast(transform.position, transform.forward, hit))
  37. {
  38. // if something is hit, check whether it's tagged "zombie":
  39. if (hit.GameObject.CompareTag("human"))
  40. { // if so, apply damage to it
  41. hit.collider.SendMessageUpwards ("dealdamage", SendMessageOptions.DontRequireReceiver);
  42. }
  43. }
  44. }
  45.  
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement