Advertisement
Guest User

Untitled

a guest
Feb 21st, 2024
7
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. public class NewBehaviourScript : MonoBehaviour {
  2.  
  3. public Transform bullet;
  4. public int BulletForce = 5000;
  5. public int Magaz = 15;
  6.  
  7. void Update () {
  8. if (Input.GetMouseButtonDown(0) && Magaz > 0) {
  9. Transform BulletInstance = Instantiate(bullet, GameObject.Find("spawn").transform.position, Quaternion.identity);
  10. BulletInstance.GetComponent<Rigidbody>().AddForce(transform.forward * BulletForce);
  11. Magaz -= 1;
  12. }
  13. if (Input.GetKeyDown(KeyCode.R)) {
  14. Magaz = 15;
  15. }
  16. }
  17. }
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement