Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class Bullet : MonoBehaviour {
- public float speed;
- public int damage = 50;
- public int headDamage = 100;
- public GameObject bloodEffect;
- public GameObject bulletHole;
- float maxDist = 1000000000;
- void Start () {
- }
- void Update() {
- transform.Translate(Vector3.forward * speed * Time.deltaTime);
- RaycastHit hit;
- if (Physics.Raycast(transform.position, transform.forward, out hit, maxDist)) {
- if (bulletHole && hit.transform.tag != "Zombie")
- Instantiate(bulletHole, hit.point + (hit.normal * 0.00001f), Quaternion.LookRotation(hit.normal * -1));
- if (hit.transform.tag == "Zombie") {
- hit.transform.gameObject.BroadcastMessage("ApplyDamage", damage);
- Instantiate(bloodEffect, transform.position, transform.rotation);
- }
- Destroy(this.gameObject);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment