Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class BulletForce : MonoBehaviour {
  5.  
  6. public float magnitude = 1.0f;
  7. public float lifeTime = 1.0f;
  8. public int damagePerShot = 20;
  9. Shooter shooter;
  10. EnemyHealth enemyHealth;
  11. GameObject player;
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19. // Use this for initialization
  20. void Awake () {
  21.  
  22. GetComponent<Rigidbody> ().AddForce (magnitude * transform.forward);
  23.  
  24. Destroy (gameObject, lifeTime);
  25.  
  26. }
  27.  
  28. void OnCollisionEnter(Collider col)
  29.  
  30. {
  31. if (col.tag == "Player")
  32. {
  33. col.GetComponent<EnemyHealth> ();
  34.  
  35. if (enemyHealth != null)
  36. {
  37. enemyHealth.TakeDamage (damagePerShot);
  38. Destroy(gameObject);
  39. }
  40.  
  41. else Destroy(gameObject);
  42. }
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement