Advertisement
MrKubic

Untitled

Mar 19th, 2018
353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.62 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class CreateMesh : MonoBehaviour {
  6.  
  7.     public GameObject enemy;
  8.     public float range = 10f;
  9.  
  10.     // Update is called once per frame
  11.     void Update () {
  12.         if(Input.GetKey(KeyCode.E)){
  13.             RaycastHit hit;
  14.             if(Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out hit, range)){
  15.                 Instantiate(enemy,hit.point, Quaternion.identity);
  16.  
  17.         }
  18.         }
  19.     }
  20.     private void OnDrawGizmos(){
  21.         Gizmos.color = Color.green;
  22.         Gizmos.DrawRay(Camera.main.transform.position, Camera.main.transform.forward * range);
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement