Advertisement
kadyr

Untitled

Oct 24th, 2021
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. using System;
  2. using UnityEngine;
  3.  
  4. public class Bullet : MonoBehaviour
  5. {
  6. private Vector3 direction;
  7.  
  8. [SerializeField]
  9. private float speed;
  10.  
  11. public void SetDirection(Vector3 dir)
  12. {
  13. direction = dir;
  14. }
  15.  
  16. void Start() { }
  17.  
  18. void Update()
  19. {
  20. transform.position += direction * Time.deltaTime * speed;
  21. }
  22.  
  23. private void OnTriggerEnter(Collider other)
  24. {
  25. if (other.tag == "Player")
  26. {
  27. other.gameObject.GetComponent<PlayerController>().ChangeHealth(-20);
  28. }
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement