Advertisement
Guest User

Untitled

a guest
Jul 21st, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class Gun : MonoBehaviour
  4. {
  5. public float damage = 10f;
  6. public float range = 10f;
  7.  
  8. public Camera fpsCam;
  9.  
  10. void Update()
  11. {
  12. if (Input.GetButtonDown("Fire1")) {
  13. Shoot();
  14. }
  15.  
  16. void Shoot() {
  17. RaycastHit hit;
  18. if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range))
  19. {
  20. Debug.Log(hit.transform.name);
  21. }
  22. }
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement