Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class Bullet : MonoBehaviour
- {
- float speed = 10;
- private int damage = 20;
- Vector3 direction;
- private void Start()
- {
- GetComponent<AudioSource>().pitch = Random.Range(0.7f, 1f);
- }
- void Update()
- {
- transform.position += direction * speed * Time.deltaTime; //���������� ���� �� ����������� �� ������
- }
- public void setDirection(Vector3 dir)
- {
- direction = dir;
- }
- public void MakeNewBullet(int setSpeed, int setDamage)
- {
- speed = setSpeed;
- damage = setDamage;
- }
- private void OnTriggerEnter(Collider other)
- {
- if (other.CompareTag("Player"))
- {
- Debug.Log("collided");
- FindObjectOfType<PlayerController>().ChangeHealth(-damage);
- }
- if (other.GetComponent<Enemy>()!=null)
- {
- other.GetComponent<Enemy>().ChangeHealth(-damage);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement