mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 22:11:38 +00:00
307 lines
8.3 KiB
YAML
307 lines
8.3 KiB
YAML
# This file is automatically generated. Please don't edit it manually.
|
||
# To submit a bug report on the content, see
|
||
# https://devforum.roblox.com/c/bug-reports/documentation-issues/72
|
||
|
||
name: HapticEffect
|
||
type: class
|
||
memory_category: Instances
|
||
summary: ''
|
||
description: |
|
||
Modern controllers and devices have motors built‑in to provide haptic
|
||
feedback. Adding rumbles and vibrations can provide subtle feedback that is
|
||
hard to convey through visuals or audio.
|
||
|
||
Roblox supports haptics for the following devices:
|
||
|
||
- Android and iOS phones supporting haptics including most iPhone, Pixel, and
|
||
Samsung Galaxy devices
|
||
- PlayStation gamepads
|
||
- Xbox gamepads
|
||
- Quest Touch controller
|
||
code_samples: []
|
||
inherits:
|
||
- Instance
|
||
descendants: []
|
||
tags: []
|
||
deprecation_message: ''
|
||
properties:
|
||
- name: HapticEffect.Looped
|
||
summary: |
|
||
Whether the haptic effect loops continuously.
|
||
description: |
|
||
Whether the haptic effect loops continuously.
|
||
|
||
```
|
||
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()
|
||
```
|
||
code_samples: []
|
||
type: boolean
|
||
tags: []
|
||
deprecation_message: ''
|
||
security:
|
||
read: None
|
||
write: None
|
||
thread_safety: ReadSafe
|
||
category: Data
|
||
serialization:
|
||
can_load: true
|
||
can_save: true
|
||
capabilities:
|
||
- Input
|
||
- name: HapticEffect.Position
|
||
summary: |
|
||
Along with `Class.HapticEffect.Radius|Radius`, specifies the impact
|
||
position relative to the input device and, effectively, how broadly that
|
||
impact effects nearby motors.
|
||
description: |
|
||
Along with `Class.HapticEffect.Radius|Radius`, specifies the impact
|
||
position relative to the input device and, effectively, how broadly that
|
||
impact effects nearby motors. Note that some gamepads do not have both
|
||
"small" and "large" motors, and that "gamepad large left/right" is not
|
||
supported on PC.
|
||
|
||
<img src="/assets/engine-api/classes/HapticEffect/Position-Radius.png" width="780" />
|
||
|
||
```
|
||
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()
|
||
```
|
||
code_samples: []
|
||
type: Vector3
|
||
tags: []
|
||
deprecation_message: ''
|
||
security:
|
||
read: None
|
||
write: None
|
||
thread_safety: ReadSafe
|
||
category: Data
|
||
serialization:
|
||
can_load: true
|
||
can_save: true
|
||
capabilities:
|
||
- Input
|
||
- name: HapticEffect.Radius
|
||
summary: |
|
||
Along with `Class.HapticEffect.Position|Position`, specifies the impact
|
||
radius relative to the input device and, effectively, how broadly that
|
||
impact effects nearby motors.
|
||
description: |
|
||
Along with `Class.HapticEffect.Position|Position`, specifies the impact
|
||
radius relative to the input device and, effectively, how broadly that
|
||
impact effects nearby motors. Note that some gamepads do not have both
|
||
"small" and "large" motors, and that "gamepad large left/right" is not
|
||
supported on PC.
|
||
|
||
<img src="/assets/engine-api/classes/HapticEffect/Position-Radius.png" width="780" />
|
||
|
||
```
|
||
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()
|
||
```
|
||
code_samples: []
|
||
type: float
|
||
tags: []
|
||
deprecation_message: ''
|
||
security:
|
||
read: None
|
||
write: None
|
||
thread_safety: ReadSafe
|
||
category: Data
|
||
serialization:
|
||
can_load: true
|
||
can_save: true
|
||
capabilities:
|
||
- Input
|
||
- name: HapticEffect.Type
|
||
summary: |
|
||
`Enum.HapticEffectType` describing the haptic type.
|
||
description: |
|
||
The haptic type, such as `Enum.HapticEffectType.GameplayCollision` for a
|
||
large immediate rumble that dies down quickly. The
|
||
`Enum.HapticEffectType.Custom` value lets you specify a haptic with custom
|
||
waveform keys defined through
|
||
`Class.HapticEffect:SetWaveformKeys()|SetWaveformKeys()`.
|
||
code_samples: []
|
||
type: HapticEffectType
|
||
tags: []
|
||
deprecation_message: ''
|
||
security:
|
||
read: None
|
||
write: None
|
||
thread_safety: ReadSafe
|
||
category: Data
|
||
serialization:
|
||
can_load: true
|
||
can_save: true
|
||
capabilities:
|
||
- Input
|
||
- name: HapticEffect.Waveform
|
||
summary: ''
|
||
description: ''
|
||
code_samples: []
|
||
type: FloatCurve
|
||
tags:
|
||
- Deprecated
|
||
deprecation_message: ''
|
||
security:
|
||
read: RobloxScriptSecurity
|
||
write: RobloxScriptSecurity
|
||
thread_safety: ReadSafe
|
||
category: Data
|
||
serialization:
|
||
can_load: true
|
||
can_save: true
|
||
capabilities:
|
||
- Input
|
||
methods:
|
||
- name: HapticEffect:Play
|
||
summary: |
|
||
Plays the haptic effect.
|
||
description: |
|
||
Plays the haptic effect.
|
||
|
||
```
|
||
local Workspace = game:GetService("Workspace")
|
||
|
||
local effect = Instance.new("HapticEffect")
|
||
effect.Type = Enum.HapticEffectType.GameplayExplosion
|
||
effect.Parent = Workspace
|
||
|
||
-- Play the haptic effect
|
||
effect:Play()
|
||
```
|
||
code_samples: []
|
||
parameters: []
|
||
returns:
|
||
- type: ()
|
||
summary: ''
|
||
tags: []
|
||
deprecation_message: ''
|
||
security: None
|
||
thread_safety: Unsafe
|
||
capabilities:
|
||
- Input
|
||
- name: HapticEffect:SetWaveformKeys
|
||
summary: |
|
||
Defines a custom waveform as a table and applies it to the haptic.
|
||
|
||
This method takes in an array of `Datatype.FloatCurveKey` objects.
|
||
description: |
|
||
This method lets you define a custom waveform as a table and apply it to
|
||
the haptic.
|
||
|
||
```
|
||
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)
|
||
```
|
||
code_samples: []
|
||
parameters:
|
||
- name: keys
|
||
type: Array
|
||
default:
|
||
summary: ''
|
||
returns:
|
||
- type: ()
|
||
summary: ''
|
||
tags: []
|
||
deprecation_message: ''
|
||
security: None
|
||
thread_safety: Unsafe
|
||
capabilities:
|
||
- Input
|
||
- name: HapticEffect:Stop
|
||
summary: |
|
||
Stops the haptic effect.
|
||
description: |
|
||
Stops the haptic effect.
|
||
|
||
```
|
||
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()
|
||
```
|
||
code_samples: []
|
||
parameters: []
|
||
returns:
|
||
- type: ()
|
||
summary: ''
|
||
tags: []
|
||
deprecation_message: ''
|
||
security: None
|
||
thread_safety: Unsafe
|
||
capabilities:
|
||
- Input
|
||
events:
|
||
- name: HapticEffect.Ended
|
||
summary: |
|
||
Fires when the `Class.HapticEffect` has completed playback and stopped.
|
||
description: |
|
||
Fires when the `Class.HapticEffect` has completed playback and stopped.
|
||
Note this event will **not** fire for haptics with
|
||
`Class.HapticEffect.Looped|Looped` set to `true` since they continue
|
||
playing upon reaching the end. This event will also **not** fire when the
|
||
haptic is stopped before playback has completed.
|
||
|
||
This event is often used to destroy an `Class.HapticEffect` when it has
|
||
completed playback.
|
||
code_samples: []
|
||
parameters: []
|
||
tags: []
|
||
deprecation_message: ''
|
||
security: None
|
||
capabilities:
|
||
- Input
|
||
callbacks: []
|