Simple VR Spectator Camera

18. September 2017 Tutorials 9
Simple VR Spectator Camera

I’m always amazed at the length of the release notes document Unreal puts out with each release.  Epic packs a ton of features into each and every release. It’s easy for new feature to sometimes get overlooked. One that caught my eye in the newest release (4.17) was the ability to set up a spectator camera for VR. This allows you to render one image to the VR headset and a completely different image to the screen. Unfortunately the documentation for this feature seems to be a little sparse. In fact at the time of the writing of this post the link on the unreal release notes for this feature is a dead link going nowhere. Thankfully it wasn’t to hard to figure out so I thought I’d share with you guys what I learned. Adding a spectator camera can be done in 3 easy steps.

  1. Create a Scene Capture Component 2d – Think of this as the camera for the spectator. I attached mine to the character actor that I was already using.
  2. Create a Render Target – This will work as the holding place for the image captured by the scene capture component 2d.
  3. Set your spectator screen mode and texture – The 4.17 came with a few improvements for how you can display to the main view-port with the “Set Spectator Screen Mode Node” including showing just one eye and displaying with or without distortion. For our purposes we just want to set it to a texture and to grab the texture from the render target we made.

And there you go. You should now be able to move that scene capture component 2d anywhere and get a good non-head mounted view of the game-play. Please note that this will impact your frame rate as you now have one more image to render each frame. So use this at your own discretion.


9 thoughts on “Simple VR Spectator Camera”

  • 1
    Michael on November 4, 2017 Reply

    Thanks very much for this! I was looking for some time for how to do this until final learning about Spectator Screen. I’m got a basic setup working with screen mode ‘texture’ and doing a scene capture through a separate camera. But the screen captures are very low resolution. Do you happen to know how to debug that? Thanks.

    • 2
      The Undead Dev on November 6, 2017 Reply

      Yeah I’m betting the resolution on your render target is set too low. Just open up the render target class you created and you should see a parameter for resolution.

      • 3
        Anonymous on November 6, 2017 Reply

        Thanks! That was it.

  • 4
    Anonymous on November 29, 2017 Reply

    Cool! I’m hoping to add something similar to my game in the near future.

    A little confused – did you write extra blueprint to take keyboard / mouse inputs that fly the capture component 2d around in world space? Or was this character a separate character from the player character, that had independent control?

    • 5
      The Undead Dev on November 29, 2017 Reply

      Yeah, so this tutorial really only goes into creating a separate spectator camera. To fly the camera around you’ll need more code.
      For UFO Rodeo I know that my VR pawn never moves, so I was fine just adding logic to capture mouse and keyboard inputs and applying them to move the capture component 2d around in the world space just as you had mentioned. However a similar effect could probably be achieved using a second actor as well. There’s no one right way to do it.

      • 6
        Anonymous on November 29, 2017 Reply

        Awesome – thanks for the info!

        I’ll probably go the second actor route. Ideally, I’d like to set up some sort of smart camera system where that actor moves to a location within line of sight and a distance tolerance of the player, then “cuts” to different locations at intervals or if the player gets out of sight. It’ll definitely be a better way to show the game to others than first person view 😀

        • 7
          The Undead Dev on November 29, 2017 Reply

          I don’t know what kind of game you are making, so this might not apply but if you are worried about the camera getting too far from the player you could always put the capture component 2d on a spring arm component ( https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/UsingCameras/SpringArmComponents/ ) . That might make keeping relative distance from player easier, plus it has the added advantages of preventing the camera from clipping through walls and always maintaining line of site with the player. It’ll likely make controls a little more complicated though.

  • 8
    Anonymous on December 5, 2017 Reply

    how exactly do i create the render target? i’m all new to this.

Comment on this post!