I would like to place the cube where i am looking with raycast.
Here is my code: (because of something t only places on the floor)
using UnityEngine;
using System.Collections;
public class RayTest : MonoBehaviour {
public Transform cubie;
public float raycastDist = 100f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
RaycastHit hit;
if(Input.GetKey("mouse 0")) {
if(Physics.Raycast(transform.position,(Vector3)transform.rotation, out hit,raycastDist)){
Debug.Log("Successfull raycast");
cubie.position = hit.point;
cubie.rotation = Quaternion.LookRotation(hit.normal);
}
else
{
Debug.Log ("Not succesfull raycast");
}
}
}
}