您的头像是您进入的任何空间中的身份。SocialInteractions 开发者模块 让每个用户更好地表达自己和他们的自然动作,为游戏增添了一丝现实感。
该模块包括以下功能:
| 身体 方向 | 使每个人的头像的头部朝向其对应用户的相机指向的方向,通过颈部和腰部的旋转混合。这提供了一个微妙的提示,表明其他人正在与谁或什么互动。 |
| 聊天 动画 | 通过使头像偶尔播放动画来为游戏内聊天增添活力,具体取决于他们发送的消息内容。激活每个动画的“触发 词”列表是可配置的。 |
模块使用
安装
要在游戏中使用 SocialInteractions 模块:
从 Studio 的 窗口 菜单或 主页 选项卡工具栏中,打开 工具箱 并选择 创作者商店 选项卡。

确保选择了 模型 排序,然后单击 查看所有 按钮以查看 类别。

找到并单击 包 瓦片。
找到 社交互动 模块并单击它,或将其拖放到 3D 视图中。

在 资源管理器 窗口中,将整个 SocialInteractions 模型移动到 ReplicatedStorage 中。运行游戏时,模块将开始运行。
配置
简单地插入 SocialInteractions 模块将启用您场所中的 身体方向 和 聊天动画 功能。要调整默认行为:
在 StarterPlayerScripts 中,创建一个新的 LocalScript 并将其重命名为 ConfigureSocialInteractions。

将以下代码粘贴到新脚本中,使用 configure 函数自定义模块的行为。
LocalScriptlocal ReplicatedStorage = game:GetService("ReplicatedStorage")local SocialInteractions = require(ReplicatedStorage.SocialInteractions)-- 使腰部旋转更明显并禁用聊天动画功能SocialInteractions.configure({waistOrientationWeight = 0.75,useChatAnimations = false,})
聊天动画触发词
激活每个聊天动画的“触发词”列表是可配置的,并且使用 Luau 字符串模式来增加可识别的单词。例如,Wave 动画使用的一个组合是 he+y+o*,这意味着 hey、heyyy、heyo、heyyyyo、heeeeyyyyo 和其他变体都符合触发动画的条件。
还要注意,触发词是 不区分大小写 的,因此输入 hey 与 HEY、Hey 和其他变体是相同的。
| 动画 | 动画 ID | 单词模式 |
|---|---|---|
| Wave | 3344650532 | hell+o+ h+i+o* wa+[sz]+u+p+ y+o+ greetings* salutations* goo+d+%smorning+ he+y+o* howdy+ what's*%s*up+ |
| Applaud | 5911729486 | ya+y+ h[ou]+r+a+y+ woo+t* woo+h+oo+ bravo+ congratulations+ congrats+ gg pog+ poggers+ |
| Agree | 4841397952 | ye+s* ye+a+h* y[eu]+p+ o+k+ o+k+a+y+ |
| Disagree | 4841401869 | no+ no+pe+ yi+ke+s+ |
| Shrug | 3334392772 | not+%s+sure+ idk+ don't%s+know+ i%s+don't%s+know+ who+%s+knows+ |
| Laugh | 3337966527 | lo+l+ rof+l+ ha[ha]* he[he]+ |
| Sleep | 4686925579 | zzz+ yawn+ |
激活每个动画的触发词列表是可配置的,并且可以通过 setTriggerWordsForChatAnimation 函数添加额外的动画。例如,以下 LocalScript 将 Tilt 动画与字符串模式 cra+zy 关联,以支持触发词如 crazy 和 craaaaaazy。它还为 Applaud 动画注册了额外的字符串模式 coo+l,以支持单词如 cool 和 coooool。
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 | 聊天动画附带默认的 触发 词 列表。如果您想关闭它们并提供自己的词,请将此参数设置为 false。 | true |
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 将接受聊天短语 woah、WOAH、Woah 和其他变体。
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SocialInteractions = require(ReplicatedStorage.SocialInteractions)
-- 注册自定义动画的新字符串模式
SocialInteractions.setTriggerWordsForChatAnimation(
"rbxassetid://3334538554",
{"cra+zy", "woah+"}
)事件
onChatAnimationPlayed
当聊天动画播放时触发。连接的函数接收动画 ID 和触发动画的单词作为参数。此事件只能在 LocalScript 中连接。
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SocialInteractions = require(ReplicatedStorage.SocialInteractions)
SocialInteractions.onChatAnimationPlayed:Connect(function(animationId, triggerWord)
print(animationId, triggerWord)
end)