Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class BulletForce : MonoBehaviour {
- public float magnitude = 1.0f;
- public float lifeTime = 1.0f;
- public int damagePerShot = 20;
- Shooter shooter;
- EnemyHealth enemyHealth;
- GameObject player;
- // Use this for initialization
- void Awake () {
- GetComponent<Rigidbody> ().AddForce (magnitude * transform.forward);
- Destroy (gameObject, lifeTime);
- }
- void OnCollisionEnter(Collider col)
- {
- if (col.tag == "Player")
- {
- col.GetComponent<EnemyHealth> ();
- if (enemyHealth != null)
- {
- enemyHealth.TakeDamage (damagePerShot);
- Destroy(gameObject);
- }
- else Destroy(gameObject);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement