> For the complete documentation index, see [llms.txt](https://tk233.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tk233.gitbook.io/notes/uw/unreal-engine-communicate-with-steamvr-and-external-python.md).

# Unreal Engine Communicate with SteamVR

## 0. Environment

Windows 10

Unreal Engine 5.1.1

SteamVR 1.25.8

## 1. Create a new Unreal project

Select "Film / Video & Live Events" -> "Blank". Leave "Starter Content" and "Raytracing" unchecked.

Click "Create" button.

<figure><img src="https://1287130752-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvVJ0h2a4qMIhB1I8GdV8%2Fuploads%2Fgit-blob-fd7468df2216b86a62105e8e73cf666b10dfef2c%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

## 2. Add plugin

Click "Edit" -> "Plugins" to open the plugins window.

<figure><img src="https://1287130752-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvVJ0h2a4qMIhB1I8GdV8%2Fuploads%2Fgit-blob-8560cf3b21285b4eb40093ba6b2f5c6b90d8200b%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

Search and add the following plugins.

<figure><img src="https://1287130752-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvVJ0h2a4qMIhB1I8GdV8%2Fuploads%2Fgit-blob-1f4d45e73be5fe26cd077ea209418b82d3dd783a%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1287130752-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvVJ0h2a4qMIhB1I8GdV8%2Fuploads%2Fgit-blob-15891b43b4a1166910fa6175404ad8e891920ebe%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1287130752-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvVJ0h2a4qMIhB1I8GdV8%2Fuploads%2Fgit-blob-03986ede50d2a079e382c76d4bacb7af748babc7%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

After adding the plugin, Unreal Engine needs to be restarted.

Before restart, make sure SteamVR is running

<figure><img src="https://1287130752-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvVJ0h2a4qMIhB1I8GdV8%2Fuploads%2Fgit-blob-fb964bde83b64df9ff7dd79c7d22a34f7cdbac04%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

## 3. Set up VR devices

<figure><img src="https://1287130752-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvVJ0h2a4qMIhB1I8GdV8%2Fuploads%2Fgit-blob-762833e52bb0bed2fd2eef156e9b4b40015eb1b5%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1287130752-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvVJ0h2a4qMIhB1I8GdV8%2Fuploads%2Fgit-blob-192dbe61a19628aaa2710b59a4b61b9cd009b476%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1287130752-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvVJ0h2a4qMIhB1I8GdV8%2Fuploads%2Fgit-blob-230c4a71acc8e866b631a95ad0f6e6126c3aa688%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

## 4.1 Bind to virtual camera

Create a virtual camera.

<figure><img src="https://1287130752-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvVJ0h2a4qMIhB1I8GdV8%2Fuploads%2Fgit-blob-5fac6ce2a69653f885e241909f0444525fe1ce24%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

Add a "Live Link Controller" component to VCam.

<figure><img src="https://1287130752-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvVJ0h2a4qMIhB1I8GdV8%2Fuploads%2Fgit-blob-966a3b42590f5d828698183365cbccdc60821bbd%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

In the "Subject Representation" field, select the desired VR device to bind.

<figure><img src="https://1287130752-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvVJ0h2a4qMIhB1I8GdV8%2Fuploads%2Fgit-blob-253560dcb74bd9c72ffe8c406e9c1958c1b75a06%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

Now the virtual camera should be controlled by the VR device.

## 4.2 Read from Blueprint

The following Blueprint code shows how to read the location of the tracker.

<figure><img src="https://1287130752-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvVJ0h2a4qMIhB1I8GdV8%2Fuploads%2Fp8Ybah6pqsWcdD0gfGIY%2Fimage.png?alt=media&amp;token=219bc936-51d2-4656-bb88-1d17cf4060ee" alt=""><figcaption></figcaption></figure>

## Reference

{% embed url="<https://www.youtube.com/watch?v=HwAra3yXVHs>" %}

{% embed url="<https://www.youtube.com/watch?v=pqbuk0nQ5Sk>" %}

Other possible methods:

{% embed url="<https://dev.epicgames.com/community/learning/tutorials/LdR2/unreal-engine-how-to-use-vive-trackers-in-ue-5-2-and-later-versions>" %}

{% embed url="<https://github.com/ValveSoftware/openxr_engine_plugins>" %}

{% embed url="<https://docs.unrealengine.com/4.26/en-US/BlueprintAPI/SteamVR/GetTrackedDevicePositionandOrien-/>" %}
