hello :), i have been trying to figure this out for ages now, all i want is instead of a cube been created i want a gameobject of my choice basically i have modeled something, nad instead of the cube i want this game object but i dunno how to do it here is the code, please help
var range : float = Mathf.Infinity;
var hit : RaycastHit;
function Update()
{
if(Input.GetMouseButtonDown(1)){
Build();
}
}
function Build()
{
if(HitBlock()){
var cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
cube.transform.position = hit.transform.position + hit.normal;
}
}
function HitBlock() : boolean
{
return Physics.Raycast(transform.position, transform.forward, hit, range);
}
Thanks.