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 CreateMesh : MonoBehaviour {
- public GameObject enemy;
- public float range = 10f;
- // Update is called once per frame
- void Update () {
- if(Input.GetKey(KeyCode.E)){
- RaycastHit hit;
- if(Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out hit, range)){
- Instantiate(enemy,hit.point, Quaternion.identity);
- }
- }
- }
- private void OnDrawGizmos(){
- Gizmos.color = Color.green;
- Gizmos.DrawRay(Camera.main.transform.position, Camera.main.transform.forward * range);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement