Instantiate rotation question.

var tempbrick : GameObject;

function Update () {

    if (Input.GetButtonDown("Brickcast")) {

    var ray : Ray = Camera.main.ViewportPointToRay (Vector3(0.5,0.5,0));   
        var hit : RaycastHit;
        if (Physics.Raycast (ray, hit, 7)) {

            Debug.DrawLine (ray.origin, hit.point);
            Instantiate(tempbrick, hit.point, Quaternion.identity);


        Physics.Raycast (ray, hit);


    Debug.DrawRay (ray.origin, ray.direction * 10, Color.white);


I want to instantiate the prefab with the same rotation as the object that the raycast collided with. How?

var rotationOfHitObject : Quaternion = hit.collider.gameObject.transform.rotation;

Put this in after casting the ray to get the rotation of the object the ray hit. Then replace Quaternion.identity with rotationOfHitObject. Untested, but I'm confident this should work. Good luck with it!