c# Raycast Mouse input!

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");
        }
    }
}
}

The second argument in the raycast method is the direction.
In this case we’ll use the forward vector from the camera.

Physics.Raycast(myCamera.transform.position, myCamera.transform.forward, out hit, raycastDist);

THANK YOU VERY MUCH. <3 <3 I have been searching for this for hours.

Haha, you’re welcome! :wink: