AWS Logo
Menu

Live Streaming from Unity - Multi-Camera Streams (Part 6)

Let's see how to stream more than one camera to the same Amazon IVS stage.

Todd Sharp
Amazon Employee
Published Feb 27, 2024
So far in this series, we've looked at broadcasting from a game built in Unity to an Amazon Interactive Video Service (Amazon IVS) real-time stage, integrated chat, and enhanced the experience with viewer-controlled cameras, and dynamic objectives and environments. In this post, we'll talk about another possible use-case: multi-camera streams.
In addition to viewer-controlled camera views, wouldn't it be super cool to see the action from multiple POVs as a stream viewer? Building on the same concepts that we've established in this series, this is totally possible.

Create a Reusable Class

Because we have some functionality that will be shared across several scripts, we'll encapsulate some of the logic that we've been using in this series into a reusable WebRTCUtils class. This will allow us to establish multiple streams from our game.

Player Stream

We'll use the 'FPS' demo game for this demo, and create a player camera to broadcast the player's POV just as we did before.
Player cam
Next, create and associate a WebRTCPlayerPublish script.

Boss Stream

To add another camera for the main turret's POV, create an empty game object on the turret called TurretCameraThing.
Turret camera thing
Because we want this camera to always look at whatever the turret is looking at, we'll need to create a TurretCameraThing script that is bound to the turret's health bar and update the turret camera's transform in Update().
Now we can add a camera as a child of TurretCameraThing and attach a new WebRTCBossPublish script that will broadcast this camera's view as a separate stream to the same Amazon IVS stage.

Testing Multi-Cam Streams

Once we launch the game, we can see that both cameras are broadcasting their own view to the Amazon IVS stage!

Summary

In this post, we learned how to broadcast multiple cameras from a game built in Unity to an Amazon IVS real-time stage. In the next post, we'll switch gears and look at real-time stream playback in a Unity game.
 

Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.

Comments