I have created a wall using a cube in Unity. Now I want to create a door in it.
How can I make a door in that cube?
Consider that the cube is automatically generated, so i have to generate the door in a C# script.
I have created a wall using a cube in Unity. Now I want to create a door in it.
How can I make a door in that cube?
Consider that the cube is automatically generated, so i have to generate the door in a C# script.
Unity primitives are not like actual 3D models, they are great for concepts but do not afford much versatility. I recommend that you start with changing your original wall prefab.
Now make a new cube and size it to fit the hole in the wall. Keep an eye on the transform position in the upper right-hand corner.
You should probably make a prefab of the door object as well.
In C# you'll want to create a "public transform door" this will be visible in the inspector. You can then Instantiate the door at the position you need the door to be. That should look something like:
Instantiate (door, door.position, Quaternion.identity);
In the unity inspector you'll want to drag and drop the door prefab in slot that appears as the door transform.
Hope that helps!