现代控制器和设备具有内置驱动器提供反馈,用于提供触觉反馈。添加隆隆声和振动可以提供难以通过视觉或音频传达的微妙反馈。
Roblox 支持以下设备的触觉:
- 支持最新 iPhone、Pixel 和 Samsung Galaxy 设备的 Android 和 iOS 手机支持震动,包括大多数 iPhone、Pixel 和 Samsung Galaxy 设备
- 游戏手柄 PlayStation
- Xbox 游戏手柄
- 任务触摸控制器
概要
属性
是否使用触觉效果循环连续。
与 Radius 一起,指定输入设备相对的影响位置,并有效地确定影响效果的广度近郊发动机。
与 Position 一起,指定输入设备相对的影响半径,并有效地确定影响附近发动机的程度。
Enum.HapticEffectType 描述了触觉类输入。
方法
播放触觉效果。
用于定义自定义波形为表并应用于震动的方法。
停止触觉效果。
属性
Looped
是否使用触觉效果循环连续。
local Workspace = game:GetService("Workspace")local effect = Instance.new("HapticEffect")effect.Type = Enum.HapticEffectType.GameplayExplosioneffect.Looped = trueeffect.Parent = Workspace-- Start the haptic effecteffect:Play()-- After two seconds, stop the effecttask.wait(2)effect:Stop()
Position
与 Radius 一起,指定输入设备相对的影响位置,并有效地确定影响效果的广度近郊发动机。请注意,一些游戏手柄没有“小”和“大”马达,“游戏手柄大左/右”在 PC 上不支持。

local Workspace = game:GetService("Workspace")local effect = Instance.new("HapticEffect")-- Set the position and radius of impacteffect.Position = Vector3.new(0.5, 0.5, 0)effect.Radius = 1effect.Parent = Workspaceeffect:Play()
Radius
与 Position 一起,指定输入设备相对的影响半径,并有效地确定影响附近发动机的程度。请注意,一些游戏手柄没有“小”和“大”马达,“游戏手柄大左/右”在 PC 上不支持。

local Workspace = game:GetService("Workspace")local effect = Instance.new("HapticEffect")-- Set the position and radius of impacteffect.Position = Vector3.new(0.5, 0.5, 0)effect.Radius = 1effect.Parent = Workspace-- Play the haptic effecteffect:Play()
触觉类输入,例如 Enum.HapticEffectType.GameplayCollision 用于快速死亡的大规模初始隆隆。 值允许您通过 定义的自定义波形键指定一种触觉,以便您通过 指定特定波形。
Waveform
方法
Play
()
播放触觉效果。
local Workspace = game:GetService("Workspace")local effect = Instance.new("HapticEffect")effect.Type = Enum.HapticEffectType.GameplayExplosioneffect.Parent = Workspace-- Play the haptic effecteffect:Play()
返回
()
SetWaveformKeys
()
这种方法可以让你将自定义波形定义为表并应用到震动上。
local Workspace = game:GetService("Workspace")local effect = Instance.new("HapticEffect")-- Set effect type to custom in order to define a waveformeffect.Type = Enum.HapticEffectType.Customeffect.Parent = Workspace-- Define the custom waveform curve through a tablelocal rampUpWaveform = {FloatCurveKey.new(0, 0.3),FloatCurveKey.new(100, 0.4),FloatCurveKey.new(300, 0.8),FloatCurveKey.new(400, 1.0)}-- Set waveform through the effect's methodeffect:SetWaveformKeys(rampUpWaveform)
参数
默认值:""
返回
()
Stop
()
停止触觉效果。
local Workspace = game:GetService("Workspace")local effect = Instance.new("HapticEffect")effect.Type = Enum.HapticEffectType.GameplayExplosioneffect.Looped = trueeffect.Parent = Workspace-- Start the haptic effecteffect:Play()-- After two seconds, stop the effecttask.wait(2)effect:Stop()
返回
()