I want to press key"F" and instantiate a object where is the end of the ray.
But when I run it says
How can I solve this problem?
using UnityEngine;
using System.Collections;
public class RayTest : MonoBehaviour {
public Transform target;
public GameObject building;
void Update(){
if (Input.GetKey (KeyCode .F)){
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hitinfo= new RaycastHit();
Physics.Raycast(ray, out hitinfo);
target.position = hitinfo.point;
GameObject ww = Instantiate (building ,target.position ,target.rotation ) as GameObject ;