9
\$\begingroup\$

How can I make a hole in an object with Unity 3D? I've something like this object and I want to make a hole in it.

\$\endgroup\$
2
  • 7
    \$\begingroup\$ Do you wish to make the hole in the editor or during gameplay? Unity does not have a built-in feature for the former, nor an easy function for the later. However, both can be achieved via code. \$\endgroup\$
    – MAnd
    Commented Dec 28, 2015 at 17:37
  • 2
    \$\begingroup\$ Do you want any old random hole in it or a distinct predefined hole at a specific location? \$\endgroup\$
    – Steven
    Commented Dec 28, 2015 at 21:29

5 Answers 5

6
\$\begingroup\$

You can't. Unity does not have CSG modeling options. You're going to either:

  1. construct your cylinder out of smaller parts
  2. model it in another program
  3. programmatically rebuild the mesh geometry at runtime. WARNING: ADVANCED TOPIC
\$\endgroup\$
2
  • \$\begingroup\$ In the advanced topic helm, there is also the option of coding a script to add that function to the editor. \$\endgroup\$
    – MAnd
    Commented Dec 28, 2015 at 17:38
  • \$\begingroup\$ @MAnd true enough, and I've used one such tool. It was a pain in the arse to use (at least, the free version, which lacked a number of features). I'd categorize that as an "advanced topic" even within the advanced topic. \$\endgroup\$ Commented Dec 28, 2015 at 17:50
5
\$\begingroup\$

As of 2020, you can do this with ProBuilder's (experimental) Boolean CSG Tool.

  1. Install ProBuilder in Window > Package Manager.
  2. Enable Experimental Features in Edit > Preferences > ProBuilder.
  3. Select two PRoBuilder objects.
  4. Tools > ProBuilder > Experimental > Boolean
  5. Change Operation to Substraction (there's also Intersection and Union, BTW) and Apply.

A new object will be created. Works great with simple shapes so far:

Making six holes with six merged cubes

\$\endgroup\$
1
  • \$\begingroup\$ This is no longer experimental. \$\endgroup\$
    – Evorlor
    Commented Jul 5, 2023 at 12:19
5
\$\begingroup\$

Not directly. But there are several ways to achieve this:

  1. Use a voxel engine. Then you can have objects that have some kind of "molecules". You can deform them in runtime.

  2. Use a runtime mesh deformation plugin.

  3. You may build your object in parts, and then attach them together in Unity, so you can create a hole by simply removing the part in the middle.

\$\endgroup\$
2
  • \$\begingroup\$ Both links appear to be dead. \$\endgroup\$ Commented Jul 5, 2022 at 16:14
  • 1
    \$\begingroup\$ @THEJOATMON Updated the first link. The second link was a runtime mesh deformation plugin named Meshinator - Realtime Mesh Deformation, it is taken down from the Asset Store and I can't find it anywhere else at the moment, but there should be plenty of similar plugins in the Asset Store. Just search for Runtime Mesh Deformation. \$\endgroup\$ Commented Jul 6, 2022 at 8:21
0
\$\begingroup\$

Maybe try Polybrush? Check out this tutorial right at 33:00 to see proof of concept. https://www.youtube.com/watch?v=GioRYdZbGGk

The woman in the video cuts custom shapes out of the plane. You can do it out of other objects too. Before you try it, make sure to install everything she tells you to in the beginning and learn how to insert an edge loop (basically a carved line) on your object at 10:05.

Personally for me, ProBuilder refused to work. I was able to load Pro Builder, but it wasn't showing my assets to add to the subtraction method. I'm using Unity 2020.1.14f1

\$\endgroup\$
0
\$\begingroup\$

For anyone who is wondering how to do this in 2023, you can use the package ProBuilder and use the subtraction tool to make a hole.

Source: https://www.youtube.com/watch?v=aearddXihnw

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .