Advertisement
kadyr

Untitled

Nov 21st, 2021
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class LightingBullet : MonoBehaviour
  4. {
  5.  
  6. private Vector3 direction;
  7. [SerializeField]
  8. private float speed;
  9. private float timer;
  10. private float lifeTime = 4f;
  11. void Update()
  12. {
  13. transform.position += direction * speed * Time.deltaTime; //���������� ���� �� ����������� �� ������
  14. timer += Time.deltaTime;
  15. if(timer>lifeTime)
  16. Destroy(this.gameObject);
  17. }
  18. public void setDirection(Vector3 dir)
  19. {
  20. direction = dir;
  21. }
  22.  
  23. private void OnTriggerEnter(Collider other)
  24. {
  25. if (other.CompareTag("Player"))
  26. {
  27. Debug.Log("collided");
  28. FindObjectOfType<PlayerController>().Damage(-damage);
  29. }
  30. }
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement