HapticEffect
*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。
現代のコントローラーとデバイスには、ハプティックフィードバックを提供するモーターが内蔵されています。バイブレーションや振動を追加すると、ビジュアルやオーディオで伝えるのが難しい微妙なフィードバックを提供できます。
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()