社交互动

*此内容使用人工智能(Beta)翻译,可能包含错误。若要查看英文页面,请点按 此处

您的化身是您进入的任何空间中的身份。 SocialInteractions 开发者模块 让每位用户更好地表达自己和他们的自然动作,为体验增添了一丝真实感。

此模块包括以下功能:

身体朝向让每个人的化身的头部朝向其对应用户的相机所指向的方向,通过颈部和腰部旋转的混合。这提供了一个微妙的提示,告诉别人某人正在与谁或什么互动。
聊天动画通过使化身偶尔播放动画,在体验中的聊天中增添一些活力,这取决于他们发送的消息内容。激活每个动画的“触发词”列表是可配置的。

模块使用

安装

要在体验中使用 SocialInteractions 模块:

  1. 从工作室的 窗口 菜单或 主页 选项卡工具栏,打开 工具箱 并选择 创作者商店 标签。

  2. 确保选择了 模型 排序,然后单击 查看所有 按钮以获取 分类

  3. 找到并点击 瓦片。

  4. 找到 社交互动 模块并点击它,或将其拖放到3D视图中。

  5. 资源管理器 窗口中,将整个 SocialInteractions 模型移动到 ReplicatedStorage。运行体验时模块将开始运行。

配置

简单地插入 SocialInteractions 模块将启用您地方的 身体朝向聊天动画 功能。要调整默认行为:

  1. StarterPlayerScripts 中,创建一个新的 LocalScript 并将其重命名为 ConfigureSocialInteractions

  2. 将以下代码粘贴到新脚本中,使用 configure 函数来自定义模块的行为。

    LocalScript

    local ReplicatedStorage = game:GetService("ReplicatedStorage")
    local SocialInteractions = require(ReplicatedStorage.SocialInteractions)
    -- 使腰部旋转更明显并禁用聊天动画功能
    SocialInteractions.configure({
    waistOrientationWeight = 0.75,
    useChatAnimations = false,
    })

聊天动画触发词

激活每个聊天动画的“触发词”列表是可配置的,并利用 Luau 字符串模式来增加可识别的单词。例如,Wave 动画使用的一种组合是 he+y+o*,这意味着 heyheyyyheyoheyyyyoheeeeyyyyo 和其他变体都可以触发该动画。

另外请注意,触发词是 不区分大小写的,因此输入 heyHEYHey 和其他变体相同。

动画动画 ID单词模式
Wave3344650532

hell+o+    h+i+o*    wa+[sz]+u+p+    y+o+    greetings*    salutations*    goo+d+%smorning+    he+y+o*    howdy+    what's*%s*up+   

Applaud5911729486

ya+y+    h[ou]+r+a+y+    woo+t*    woo+h+oo+    bravo+    congratulations+    congrats+    gg    pog+    poggers+   

Agree4841397952

ye+s*    ye+a+h*    y[eu]+p+    o+k+    o+k+a+y+   

Disagree4841401869

no+    no+pe+    yi+ke+s+   

Shrug3334392772

not+%s+sure+    idk+    don't%s+know+    i%s+don't%s+know+    who+%s+knows+   

Laugh3337966527

lo+l+    rof+l+    ha[ha]*    he[he]+   

Sleep4686925579

zzz+    yawn+   

激活每个动画的触发词列表是可配置的,可以通过 setTriggerWordsForChatAnimation 函数添加额外的动画。例如,以下的 LocalScriptTilt 动画与字符串模式 cra+zy 关联,以支持 crazycraaaaaazy 等触发词。同时,它还为 Applaud 动画注册了一个额外的字符串模式 coo+l,以支持 coolcoooool 等单词。

LocalScript

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SocialInteractions = require(ReplicatedStorage.SocialInteractions)
-- 注册 "Tilt" 动画的字符串模式
SocialInteractions.setTriggerWordsForChatAnimation("rbxassetid://3334538554", {"cra+zy"})
-- 注册 "Applaud" 动画的附加字符串模式
SocialInteractions.setTriggerWordsForChatAnimation("rbxassetid://5911729486", {"coo+l"})

API 参考

函数

configure

configure(config: table)

通过 config 表中的以下键/值覆盖默认配置选项。此函数只能从 LocalScript 中调用。

描述默认值
useBodyOrientation切换 身体朝向 功能。true
waistOrientationWeight身体朝向使用腰部和颈部旋转的混合;此参数决定两者中的哪一个更为突出。值为 1 时完全强调腰部,而 0 则完全强调颈部。0.5
useChatAnimations切换 聊天动画 功能。true
useDefaultTriggerWordsForChatEmotes聊天动画带有默认的 触发词 列表。如果您希望关闭它们并提供自己的词,请将此参数设置为 falsetrue
LocalScript

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SocialInteractions = require(ReplicatedStorage.SocialInteractions)
-- 使腰部旋转更明显并禁用聊天动画功能
SocialInteractions.configure({
waistOrientationWeight = 0.75,
useChatAnimations = false,
})

setTriggerWordsForChatAnimation

setTriggerWordsForChatAnimation(animationId: string, triggerWords: table)

在聊天动画功能中注册一个新动画。输入任何与 triggerWords 表中包含的字符串模式匹配的单词将激活作为第一个参数传递的动画 ID。

请注意,触发词对于玩家是 不区分大小写的,因此模式为 woah 将接受聊天短语 woahWOAHWoah 和其他变体。

LocalScript

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SocialInteractions = require(ReplicatedStorage.SocialInteractions)
-- 为自定义动画注册新的字符串模式
SocialInteractions.setTriggerWordsForChatAnimation(
"rbxassetid://3334538554",
{"cra+zy", "woah+"}
)

事件

onChatAnimationPlayed

当聊天动画播放时触发。连接的函数将接收动画 ID 和激活动画的单词作为参数。此事件只能在 LocalScript 中连接。

参数
animationId: string 播放的动画 ID。
triggerWord: string激活动画的聊天单词。
LocalScript

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SocialInteractions = require(ReplicatedStorage.SocialInteractions)
SocialInteractions.onChatAnimationPlayed:Connect(function(animationId, triggerWord)
print(animationId, triggerWord)
end)
©2026 Roblox Corporation、Roblox、Roblox 标志及 Powering Imagination 是我们在美国及其他国家或地区的注册与未注册商标。