Giter VIP home page Giter VIP logo

livekit-unity-webgl-demo's Introduction

LiveKit with Unity WebGL - Spatial Audio

This repository will guide you setting up LiveKit for your browser based game Unity game. (WebGL builds only.)

Screenshot 2022-05-09 at 9 20 05 PM

Note the classes:

  • LiveKitSetup, on the root of the player prefab,
  • LiveKitAudio, this is where connecting to a room & all the other callbacks are/will be registered.
  • The setup script enables the audio script on only the local clients, but the sphere colliders are enabled for all other clients.

There are 2 touchpoints for spatial audio:

  1. When a player's sphere collider overlaps with another (and their audio tracks are already published) player's sphere collider, we add them to the local player's rangeList and also subscribe to their tracks,
  2. When a player publishes their audio tracks, all other players subscribe to their tracks if that player happens to be near them.

If you take care of these 2 cases, you will have a neat, working spatial audio implementation, barring edge cases that you'll have to account for.

A few steps in Unity to make sure everything works correctly:

  • Ensure in Player Settings -> Physics, LiveKitAudio layer only interacts with LiveKitAudio layer.

Screenshot 2022-06-07 at 7 04 21 PM

  • The sphere collider on the LiveKitAudio Game Object on the player prefab must be disabled.
  • Assign the sphere collider of this GameObject into the Setup script on the root of the player prefab.

livekit-unity-webgl-demo's People

Contributors

rohanmayya avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.