Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class FpsShooter : MonoBehaviour
- {
- public float distance = 100f;
- public KeyCode key = KeyCode.Mouse0;
- public Transform point;
- void Update ()
- {
- if (Input.GetKey(key))
- {
- RaycastHit hit;
- if (Physics.Raycast(point.position, point.forward, out hit, distance))
- {
- Debug.DrawRay(point.position, point.forward * hit.distance, Color.red);
- if (hit.transform.CompareTag("Enemy"))
- {
- Destroy(hit.transform.gameObject);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement