Quantcast
Channel: Answers by "belvita"
Viewing all articles
Browse latest Browse all 91

Answer by belvita

$
0
0
ok done for you attach this script 2 ur camera create a prefab in unity and attach the object that u want to instantiate to that prefab then after attaching the code below to camera drag your prefab to the prefab variable on inspector inside this code. Hope u know this basics.Vote me please VOTE ////////////////////////////////////////////////////////////////////////////////////////////////////////////// using UnityEngine; using System.Collections; public class instanciateobjectonclick : MonoBehaviour { Ray ray; RaycastHit hit; public GameObject prefab; // Use this for initialization void Start () { } // Update is called once per frame void Update () { ray=Camera.main.ScreenPointToRay(Input.mousePosition); if(Physics.Raycast(ray,out hit)) { if(Input.GetKey(KeyCode.Mouse0)) { GameObject obj=Instantiate(prefab,new Vector3(hit.point.x,hit.point.y,hit.point.z), Quaternion.identity) as GameObject; } } } }

Viewing all articles
Browse latest Browse all 91

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>