jmgek
1
SetObject = GameObject.CreatePrimitive(PrimitiveType.Cube);
SetObject.transform.position = hit.transform.position + hit.normal;
Can you please show me how to make this a prefab instead of a primatve. I have been trying to understand it for a while now.
In your inspector you have SetObject, drop your prefab there. To stop the cube from replacing it, comment that line out :
// SetObject = GameObject.CreatePrimitive(PrimitiveType.Cube);
and replace it with an Instantiate : Unity - Scripting API: Object.Instantiate
var clone : GameObject = Instantiate( SetObject, Vector3.zero, Quaternion.identity );
you can still change the position as you did the cube, or pass the position in the instantiate command instead (where it says Vector3.zero).
clone.transform.position = hit.transform.position + hit.normal;