HapticEffect

非推奨を表示

*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。

閲覧できません

現代のコントローラーとデバイスには、ハプティックフィードバックを提供するモーターが内蔵されています。バイブレーションや振動を追加すると、ビジュアルやオーディオで伝えるのが難しい微妙なフィードバックを提供できます。

Roblox は次のデバイスのためのハプティクスをサポートします:

  • Android と iOS の電話は、ほとんどの iPhone、Pixel、および Samsung Galaxy デバイスを含むハプティクスをサポートします
  • プレイステーションゲームパッド
  • Xbox ゲームパッド
  • クエストタッチコントローラ

概要

プロパティ

  • 並列読み取り

    ハプティック効果ループが連続して再生するかどうか。

  • 並列読み取り

    以下の Radius とともに、入力デバイスに対する影響位置と、効果が近くのモーターに及ぶ範囲を効果的に指定します。

  • 並列読み取り

    以下の Position とともに、入力デバイスに対する影響範囲と、効果範囲が近くのモーターにどれほど広がるかを指定します。

  • 並列読み取り

    Enum.HapticEffectType ハプティックタイプを説明する。

  • Robloxのスクリプトセキュリティ
    並列読み取り

方法

  • Play():()

    ハプティック効果を再生します。

  • カスタム波形をテーブルとして定義し、ハプティックに適用する方法。

  • Stop():()

    ハプティック効果を停止します。

プロパティ

Looped

並列読み取り

ハプティック効果ループが連続して再生するかどうか。


local Workspace = game:GetService("Workspace")
local effect = Instance.new("HapticEffect")
effect.Type = Enum.HapticEffectType.GameplayExplosion
effect.Looped = true
effect.Parent = Workspace
-- Start the haptic effect
effect:Play()
-- After two seconds, stop the effect
task.wait(2)
effect:Stop()

Position

並列読み取り

以下の Radius とともに、入力デバイスに対する影響位置と、効果が近くのモーターに及ぶ範囲を効果的に指定します。いくつかのゲームパッドには「小」と「大」のモーターの両方がないことに注意してください、および「ゲームパッド大左/右」は PC ではサポートされていません。


local Workspace = game:GetService("Workspace")
local effect = Instance.new("HapticEffect")
-- Set the position and radius of impact
effect.Position = Vector3.new(0.5, 0.5, 0)
effect.Radius = 1
effect.Parent = Workspace
effect:Play()

Radius

並列読み取り

以下の Position とともに、入力デバイスに対する影響範囲と、効果範囲が近くのモーターにどれほど広がるかを指定します。いくつかのゲームパッドには「小」と「大」のモーターの両方がないことに注意してください、および「ゲームパッド大左/右」は PC ではサポートされていません。


local Workspace = game:GetService("Workspace")
local effect = Instance.new("HapticEffect")
-- Set the position and radius of impact
effect.Position = Vector3.new(0.5, 0.5, 0)
effect.Radius = 1
effect.Parent = Workspace
-- Play the haptic effect
effect:Play()
並列読み取り

大きな即時震動が素早く死亡するよう入力、Enum.HapticEffectType.GameplayCollision のようなハプティックタイプ。Enum.HapticEffectType.Custom 値は、SetWaveformKeys() を通じて定義されたカスタム波形キーを使用して、ハプティックを指定できます。

Waveform

Robloxのスクリプトセキュリティ
並列読み取り

方法

Play

()

ハプティック効果を再生します。


local Workspace = game:GetService("Workspace")
local effect = Instance.new("HapticEffect")
effect.Type = Enum.HapticEffectType.GameplayExplosion
effect.Parent = Workspace
-- Play the haptic effect
effect:Play()

戻り値

()

SetWaveformKeys

()

このメソッドでは、カスタム波形をテーブルとして定義し、ハプティックに適用できます。


local Workspace = game:GetService("Workspace")
local effect = Instance.new("HapticEffect")
-- Set effect type to custom in order to define a waveform
effect.Type = Enum.HapticEffectType.Custom
effect.Parent = Workspace
-- Define the custom waveform curve through a table
local 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 method
effect:SetWaveformKeys(rampUpWaveform)

パラメータ

keys: Array
既定値: ""

戻り値

()

Stop

()

ハプティック効果を停止します。


local Workspace = game:GetService("Workspace")
local effect = Instance.new("HapticEffect")
effect.Type = Enum.HapticEffectType.GameplayExplosion
effect.Looped = true
effect.Parent = Workspace
-- Start the haptic effect
effect:Play()
-- After two seconds, stop the effect
task.wait(2)
effect:Stop()

戻り値

()

イベント