Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class shootcontroller : MonoBehaviour
  6. {
  7. public GameObject Bullet;
  8. public float Shootspace;
  9. public float Shootintensity;
  10. private float ShootCounter;
  11.  
  12. // Start is called before the first frame update
  13. void Start()
  14. {
  15.  
  16. }
  17.  
  18. // Update is called once per frame
  19. void Update()
  20. {
  21. ShootCounter -= Time.deltaTime;
  22.  
  23. if ((Input.GetKey(KeyCode.Mouse0) || Input.GetKey(KeyCode.Q)) && ShootCounter <= 0)
  24. {
  25. ShootCounter = Shootspace;
  26. GameObject bl = Instantiate(Bullet, transform.position, transform.rotation);
  27. Rigidbody rb = bl.GetComponent<Rigidbody>();
  28. rb.AddForce(transform.forward * Shootintensity);
  29. Destroy(bl, 6.0f);
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement