# In-world hologram UI - Showing an in world screen with a message (Part 2)

> Learn how to create in-world hologram UI elements with Gameface in Unreal Engine.

> Documentation index: https://coherent-labs.com/llms.txt lists every page of this documentation as Markdown; the full text is in https://coherent-labs.com/llms-full.txt.

Source: https://coherent-labs.com/blog/uitutorials/hologram-ui/hologram-ui-part-2/

## In-world hologram UI - Showing an in world screen with a message (Part 2)

ui tutorials

1/7/2025

Kaloyan Geshev

1. Showcase Overview
2. Adding an in-world view
   1. Creating the In-World Plane
   2. Setting Up the In-World Plane
3. Remove collision from the in world view
4. Make in-world view accessible in the level blueprint
5. Frontend
   1. Wrapper Structure
   2. Interactivity
   3. CSS and Animations
6. What is next?

In this tutorial, we will continue building our game with in-world hologram elements.

You can find the rest of the Hologram UI series here.

## Showcase Overview

In this part, we’ll add an in world screen on top of the box created in the previous tutorial. This screen will display a message indicating that the player can access their inventory when near the box. Additionally, we’ll add smooth transitions to the UI - the screen will close when the player opens their inventory by pressing the `P` key and reopen when the inventory is closed. However, the backend implementation of this functionality will be covered in the next tutorial and in this one we will focus on the UI.

## Adding an in-world view

To begin, we’ll add an in-world UI. Since we’ll use multiple in-world views (e.g., the current one and a 3D player inventory menu), it’s more efficient to create a separate Blueprint class for each view rather than adding them directly via the Gameface plugin menu’s `Add In-World UI` option, as described in the documentation [here ](https://docs.coherent-labs.com/unreal-gameface/integration/gettingstarted/#4-add-in-world-ui).

### Creating the In-World Plane

1. Locate the `CohtmlPlane` class in `Content/Plugins/Gameface Content` using the Content Browser.

**Note: If the `CohtmlPlane` class isn’t visible, first use the `Add In-World UI` option in the plugin to generate the class.**

2. Duplicate the `CohtmlPlane` class and rename it `InWorldPlane` for this tutorial.

3) Drag and drop the `InWorldPlane` Blueprint class into the world and position it on top of the box.

### Setting Up the In-World Plane

1. Open the `InWorldPlane` Blueprint class and access the `Details` panel.
2. Select the `Cohtml` component and change the URL to `coui://uiresources/HologramUI/in-world-screen.html`.

3) Disable game input for the in-world view - in the `Cohtml` component, uncheck the `Receive Input` option.

With this setup, the UI from the `in-world-screen.html` page will render on the plane above the box.

## Remove collision from the in world view

To allow the player to pass through the in-world view, remove its collision:

1. Open the `InWorldPlane` Blueprint class and access the Details panel.
2. Select the `StaticMesh` component.
3. Search for `Collision` and set `Collision Presets` to `No Collision`.

After changing this, the player will be able to walk through the plane, as shown below:

## Make in-world view accessible in the level blueprint

To program the behavior of the in-world view, we’ll make it accessible within the Level Blueprint:

1. Extend the `InitVariables` method created in the previous tutorial here.
2. Create a new variable in the Level Blueprint: 2.1. Name: `In World Screen` 2.2. Type: `Gameface Component`
3. Set the variable:
   - Use the `Get All Actors of Class` node with `Actor Class` set to `InWorldPlane`.
   - Retrieve the first item from the results.
   - Access the `Cohtml` component of the retrieved actor and assign it to the `In World Screen` variable.

With this setup, you can now reference the in-world view in the Level Blueprint to implement functionality such as closing and opening the screen when the player toggles their inventory. This functionality will be detailed in the next tutorial.

## Frontend

For the frontend, we’ll reuse the animated overlay effect from the first part of this tutorial series. This effect creates a noise-like appearance with animated overlay lines.

First let’s start with the `HTML` structure for the UI:

```html
<!DOCTYPE html>
<html lang="en">

<head>
    <link
        rel="stylesheet"
        href="./in-world-screen-styles.css"
    >
</head>

<body>
    <div class='in-world-screen'>
        <div class="overlay">
            <div class="overlay-lines"></div>
            <div class="overlay-radial"></div>
        </div>
        <div class="wrapper">
            <div class="icon"></div>
            <div class="text">
                Inventory
            </div>
        </div>
    </div>
    <script src="../javascript/cohtml.js"></script>
    <script>
        const screen = document.querySelector('.in-world-screen');

        engine.whenReady.then(() => {
            engine.on('playerMenuOpened', () => {
                screen.classList.toggle('hide-screen', true);
            });

            engine.on('playerMenuClosed', () => {
                screen.classList.toggle('hide-screen', false);
            });
        });
    </script>
</body>

</html>
```

### Wrapper Structure

The main wrapper (`in-world-screen`) contains:

1. An overlay element for the noise effect with two layers:
   - `overlay-lines` for animated horizontal lines.
   - `overlay-radial` for a radial gradient that subtly fades the corners.
2. A wrapper element holding the icon and the text (`Inventory`), arranged vertically with a flex column layout.

### Interactivity

1. The `cohtml.js` library is included to enable communication between the engine and the UI.
2. The UI listens for two events triggered by the engine:
   - `playerMenuOpened`: Hides the in-world screen with a transition by adding the `hide-screen` class.
   - `playerMenuClosed`: Displays the in-world screen again by removing the `hide-screen` class.

### CSS and Animations

The noise effect is achieved using CSS animations:

1. `overlay-lines` uses a `linear-gradient` background animated along the x-axis to simulate moving noise lines.
2. `overlay-radial` uses a `radial-gradient` with opacity animations to create a flickering effect.

Icon animation is achieved by rotating the icon along the Y-axis between `0°` and `180°`, then back to `0°`.

For complete details, check the `in-world-screen-styles.css` file source:

```css
body {
    width: 100vw;
    height: 100vh;
}

.overlay,
.overlay-lines,
.overlay-radial {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999;
}

.overlay {
    mask-image: radial-gradient(circle, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0.5327380952380952) 65%, rgba(255, 255, 255, 0) 100%);
    mask-size: 90% 90%;
    mask-position: center;
}

.overlay-lines {
    background-image: linear-gradient(rgba(0, 200, 228, 0.1) 0%, rgba(0, 200, 228, 0.1) 30%, rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, 0) 100%);
    background-size: 100% 30px;
    animation: overlay-anim 3s forwards linear infinite;
}

.overlay-radial {
    background-image: radial-gradient(circle, rgba(0, 200, 228, 0.2) 0%, rgba(255, 255, 255, 0) 90%, rgba(255, 255, 255, 0) 100%);
    background-size: 200%;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0;
    animation: overlay-radial-anim 3s forwards linear infinite;
    z-index: 998;
}

@keyframes overlay-anim {
    from {
        background-position: 0% 0%;
    }

    to {
        background-position: 0% -10%;
    }
}

@keyframes overlay-radial-anim {
    0% {
        opacity: 0;
    }

    1% {
        opacity: 1;
    }

    5% {
        opacity: 0;
    }

    19% {
        opacity: 0;
    }

    20% {
        opacity: 1;
    }

    25% {
        opacity: 0;
    }

    59% {
        opacity: 0;
    }

    60% {
        opacity: 1;
    }

    65% {
        opacity: 0;
    }

    100% {
        opacity: 0;
    }
}

.in-world-screen {
    background-color: rgb(0, 0, 0, 0);
    color: white;
    width: 100vw;
    height: 100vh;
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 500ms;
    transform-origin: bottom;
}

.hide-screen {
    transform: scaleY(0);
}

.wrapper {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.icon {
    background-image: url(./assets/iconBackpackSpecial.svg);
    background-repeat: no-repeat;
    background-size: contain;
    height: 35rem;
    width: 35rem;
    animation: rotate-icon 2.5s ease-in-out forwards infinite;
}

@keyframes rotate-icon {
    0% {
        transform: rotateY(0deg);
    }

    25% {
        transform: rotateY(180deg);
    }

    50% {
        transform: rotateY(0deg);
    }
}

.text {
    font-size: 7rem;
}
```

The icon used for this example is as follows:

## What is next?

In the next part of this tutorial, we’ll focus on implementing the backend in Unreal Engine to support the inventory menu.

## On this page
