Advertisement
Guest User

script

a guest
Jan 20th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.69 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class FpsShooter : MonoBehaviour
  6. {
  7.     public float distance = 100f;
  8.     public KeyCode key = KeyCode.Mouse0;
  9.  
  10.     public Transform point;
  11.  
  12.     void Update ()
  13.     {
  14.         if (Input.GetKey(key))
  15.         {
  16.             RaycastHit hit;
  17.             if (Physics.Raycast(point.position, point.forward, out hit, distance))
  18.             {
  19.                 Debug.DrawRay(point.position, point.forward * hit.distance, Color.red);
  20.                 if (hit.transform.CompareTag("Enemy"))
  21.                 {
  22.                     Destroy(hit.transform.gameObject);
  23.                 }
  24.             }
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement