Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class Bullet : MonoBehaviour
- {
- float speed = 30;
- Vector3 direction;
- private int damage = 20;
- private void Start()
- {
- GetComponent<AudioSource>().pitch = Random.Range(0.8f, 1.2f);
- }
- public void MakeSniper()
- {
- speed = 50;
- damage = 50;
- }
- void Update()
- {
- transform.position += direction * speed * Time.deltaTime;
- }
- public void setDirection(Vector3 dir)
- {
- direction = dir;
- }
- private void OnTriggerEnter(Collider other)
- {
- if (other.tag == "Player")
- {
- other.gameObject.GetComponent<PlayerController>().ChangeHealth(-20);
- }
- if (other.GetComponent<Enemy>() != null)
- {
- other.GetComponent<Enemy>().ChangeHealth(-20);
- }
- Destroy(gameObject);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement