Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class Gun : MonoBehaviour
- {
- public float damage = 10f;
- public float range = 10f;
- public Camera fpsCam;
- void Update()
- {
- if (Input.GetButtonDown("Fire1")) {
- Shoot();
- }
- void Shoot() {
- RaycastHit hit;
- if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range))
- {
- Debug.Log(hit.transform.name);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement