現代控制器和裝置具有內置馬達,用於提供觸覺反回饋。添加隆隆聲和振動可以提供難以通過視覺或聲音訊傳達的微妙反饋。
Roblox 支持以下裝置的觸感:
- 支持震動的 Android 和 iOS 手機,包括大多數 iPhone、Pixel 和 Samsung Galaxy 裝置
- 遊戲平台游戲手柄
- 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 用於快速死亡的大規模即時隆隆聲。Enum.HapticEffectType.Custom讓您指定通過SetWaveformKeys()定義的醫療波形鑰匙來指定一個醫療波形。
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()
返回
()