文档

​
​

Development

User Acquisition

Monetization

工业

Vivox Unity SDK

Vivox Unity SDK

Vivox
​
​
Vivox Unity SDK
  • Overview
  • Get started
  • Release notes
  • Developer guide
    • Set up your project
    • Create voice and text channels
      • Channel management
      • Channel name criteria
      • Channel types
      • Positional channels
        • Large 3D channels setting
        • Positional channel properties
        • Positional channel configuration
      • Channel identifiers for large scale games
      • Participant management
      • Join a channel
      • Leave a channel
      • Channel webhooks
      • Automatic connection recovery
    • Messaging
    • Player management
    • Device management
    • Audio management
    • Mobile development
    • Text-to-speech
    • Speech-to-text
    • Real-time recording
    • Server-side-recording
    • Troubleshooting
  • Tutorials
  • Reference
  1. Vivox Unity SDK 文档
  2. Vivox Unity 开发者指南
  3. 频道

位置频道配置

Configure positional channels for spatial audio in 3D environments.
阅读时间3 分钟
最后更新于 8 个月前

如果游戏加入了位置频道,则必须经常向 Vivox SDK 更新用户在与该频道关联的 3D 空间中的位置和方向。客户端通过调用
VivoxService.Instance.Set3DPosition(GameObject participantObject, string channelName)
方法来执行此操作,其中 GameObject 表示场景中的玩家,channelName 表示连接了音频的活动位置频道。此外,您还可以连接 TextState,但如果要设置位置,则必须连接到音频。
参与者在位置频道中的位置会影响他们能够听到的人,以及感知的其他玩家语音的响度和方向。启用文本后,位置会限定于仅向发送方可听范围内的用户发送文本消息。
位置频道使用右手坐标系。当玩家化身面朝正前方站立时,以下条件适用:
  • 正向 X 轴在化身右侧。
  • 正向 Y 轴从化身双脚向上穿过其头部。
  • 正向 Z 轴从化身胸部到其后背。
当玩家加入位置频道时,玩家化身被放置在一个空位置,直到他们移动到一个位置。
当玩家加入位置频道时,玩家化身被放置在一个空位置,直到他们移动到一个位置。
注意
Unity 使用左手 Y-up 世界坐标系(正 X 轴在右侧,正 Y 轴在上方,正 Z 轴进入屏幕中)。坐标系之间的转换由 Vivox SDK 在内部进行处理,不要手动执行此转换。
设置并加入具有任何配置的 3D 属性的位置频道之后,随后可向 Vivox SDK 报告角色的位置和方向。
以下代码示例说明如何在位置频道中设置用户的位置:
using UnityEngine;using Unity.Services.Vivox;class PositionalChannelExample : MonoBehaviour{ . . . // For this example, _nextPosUpdate has been initialized as Time.time at // game start. _localPlayerGameObject is the GameObject controlled by the local player. void Update() { . . . if (Time.time > _nextPosUpdate) { VivoxService.Instance.Set3DPosition(_localPlayerGameObject, activePositionalChannelName); _nextPosUpdate += 0.3f; // Only update after 0.3 or more seconds } . . . } . . .}
此示例代码演示可限制发送的 3D 位置更新数量的方法。例如,更新方法中的一种简单时间跟踪技术可以将更新尝试的速率限制为每秒合理的次数。在示例方法
Update3DPosition
中,自定义 CachedPosition 类缓存玩家的位置和方向,如果值发生变化,则允许调用
Set3DPosition
。

Copyright © 2026 Unity Technologies
法律信息隐私政策CookiesDocumentation Terms of Use请勿出售或分享我的个人信息您的隐私选择(Cookie 设置)

“Unity”、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属公司在美国和其他地方的商标或注册商标(此处查看更多信息)。其他名称或品牌是其各自所有者的商标。

为方便起见,一些页面是机器翻译的,可能包含不准确的内容。如有信息不一致的情况,以英文版本为准。


    报告此页面的问题