Applying Transparency | Unity Tutorial

Appearance is everything when it comes to game design. Want to make a transparent object in your game? Let’s do it. If you are a beginner and want to learn how to build virtual reality games, check out our Unity 3D course

Suppose we have a cube in the Scene that has color applied to it with the material ColorMaterial. Changing the cube’s transparency takes more steps than you might think.

Select ColorMaterial. Select the color box beside “Albedo” in the Inspector. Try changing the alpha value. Cube’s appearance will not change. Changing the RGB values of an object updates the cube’s color instantly. However, the same is not true for changing an object’s transparency.

To learn how to change an object’s alpha, let’s create a wall that we will make semi-transparent. Right-click in the Hierarchy. Select 3D Object > Cube to create a new cube, which will be called “Cube (1)”.

In the Inspector, change Cube’s X position to 0, Y position to 0, and Z position to -1. Change Cube’s Z Scale value to 0.2. Make Cube’s X and Y values 3. Rename Cube “GlassWall”.

Let’s make a material for GlassWall. Right-click in the Project window. Select Create > Material to create a new material. Name the material “GlassWallMaterial”.

To apply GlassWallMaterial to GlassWall, select the material and drag it to the Element 0 field in GlassWall’s Mesh Renderer component.

Select GlassWallMaterial. Change the material’s color to blue. Decrease the alpha value to half its default.

Transparency is a heavy operation. It takes a lot of performance to render a scene with many transparent objects. Therefore, you need to specifically tell the renderer that you want to apply a change in transparency. Otherwise, you could be wasting resources.

In the Inspector for the GlassWallMaterial, change the Rendering Mode from “Opaque” to “Transparent”. GlassWallMaterial’s transparency will change in the Scene.

To make the transparency change more visible, you can decrease GlassWallMaterial’s alpha value. To learn more about Unity, check out our Unity 3D course, where you build 30 virtual reality games!

Mammoth Interactive Favicon

Why you NEED to take this course :

Get in Touch.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

EMAIL US

support@mammothinteractive.com