[Studio Beta] Introducing New Haptics Effects and APIs

Hi Creators!

We’re excited to give you new haptics capabilities via a Studio beta! Haptic effects refer to tactile feedback – such as a buzz or a rumble – used to enhance immersion in a game. During the Studio beta, you can opt into usage of the API via the Beta features tab. We are hoping to use this beta to gather developer feedback – please let us know if you have any thoughts below!

We’re delivering:

  1. Predefined enum-based haptic effects: We are introducing five out-of-the-box haptic effects for developers to add to their experiences. They will work across all haptic-supported input devices. The five effects we’ll introduce are: Explosion, Collision, UIClick, UIHover, and UINotification.
  2. Customizable waveform effects: We are giving developers the ability to customize their own waveform haptic effects. This API abstracts away hardware details, so custom waveforms will work across haptic-supported input devices, given hardware limitations.
  3. Integrated Gui haptics: A no-code method of integrating haptics into your game UI, via properties HoverHaptic and ClickHaptic on ImageButtons and TextButtons.

Haptic effects currently run locally in Studio (edit, play, and test on a local server). They can’t be used in production experiences during the Studio Beta. We plan to have a client beta soon to allow you to publish experiences. Once we release haptics to client, they will be available on haptic-enabled input devices across mobile phones, Gamepads, and VR controllers.*

*Note: The following combinations of client platforms + input devices do not yet support haptics. We are working to fix these piecewise.

  • Android11 and below
  • MacOS 15+ with controllers
  • Mobile devices with controllers
  • PC-VR

Keep reading for details!


How to Enable this Beta

To enable this beta in Roblox Studio, follow these simple steps:

  1. Open Roblox Studio and navigate to the “File” menu.
  2. Click on “Beta Features”.
  3. Enable the “Haptic Effects” option by checking the corresponding checkbox (see screenshot below) and press Save.

  1. Restart Roblox Studio when prompted.

How to Use the HapticEffect API

We’ll walk you through the basics of how to use the HapticEffect API in this post. You can find detailed API documentation here.

Get Started with Our Predefined Effects

To cover some common use cases of haptics, we’re providing five predefined effects:

  1. UIHover: Useful for when a player browses over an object (often a UI object) without triggering its action.
  2. UIClick: Useful for when a player has selected an object (often a UI object) with the intention of triggering its action.
  3. UINotification: Useful for when there is an inbound message that should draw the player’s attention away from their current gameplay.
  4. GameplayExplosion: Useful to signify a large-scale physics event that triggers impact across a large portion of a given scene.
  5. GameplayCollision: Useful to signify a clear and purposeful impact between objects.

These can be accessed by setting Enum.HapticEffectType to their corresponding number. Here’s an example:

Click here to view the Code Block
-- create a predefined effect --
local effectPredefined = Instance.new("HapticEffect")
effectPredefined.Parent = workspace
effectPredefined.Type = Enum.HapticEffectType.GameplayExplosion
effectPredefined:Play()

If you want to try out these effects, check out our sample placefile, HapticWorld!

HapticWorld.rbxl (187.2 KB)

Make Your Own Custom Waveforms

It’s easy to create your own custom haptic effects as well! Here’s an example where we create a custom effect that gradually intensifies.

Click here to view the Code Block
-- First, define the custom curve we want to use.
local rampUpWaveform = {
      FloatCurveKey.new(0, 0.3),
      FloatCurveKey.new(100, 0.4),
      FloatCurveKey.new(300, 0.8),
      FloatCurveKey.new(400, 1.0)
}
local effectCustom = Instance.new("HapticEffect")

-- Next, set the effect type to Custom so we can define our own waveform.

effectCustom.Type = Enum.HapticEffectType.Custom

-- Then, set the keys of the waveform. This errors if Type ~= "Custom".

effectCustom:SetWaveformKeys(rampUpWaveform)

-- Optionally, we can set the position of impact and radius. Here, we have the impact hitting the right side of the input device (X=1).
effectCustom.Position = Vector3.new(1, 0, 0)
effectCustom.Radius = .8
effectCustom.Parent = workspace
effectCustom:Play()

Example

Our sample placefile HapticWorld uses multiple haptic effects. The goal of this game is to dodge exploding balls that will fall from the sky. Check out our placefile if you want to take a look under the hood!

HapticWorld.rbxl (187.2 KB)

If you’re looking for a visual way to design custom waveforms, you can leverage the existing Number Sequence Editor to draw line segments! This makes it easy to create and fine-tune custom haptic effects. To set this up in Studio, follow these steps:

  1. Create a HapticEffect Instance and name it “CustomHapticEffectInstance”.
  2. Change the “CustomHapticEffectInstance” type to Custom.
  3. Create a NumberSequence attribute on the “CustomHapticEffectInstance” instance and name it “WaveformCurve”.
  4. Create a Number attribute on the “CustomHapticEffectInstance” instance and name it “WaveformLengthMS”.
  5. Use NumberSequence editor to generate a waveform curve.
  6. Use “WaveformLengthMS” to specify the duration (in milliseconds) of the haptic effect.
  7. Create a script under the “CustomHapticEffectInstance” instance and insert the following code:
Click here to view the Code Block
-- Converts a NumberSequence attribute to a FloatCurve suitable for custom waveforms in HapticEffect.

local hapticInstance = script.Parent
local waveformCurve = hapticInstance:GetAttribute("WaveformCurve") -- a NumberSequence attribute to represent waveform
local waveformCurveLengthMS = hapticInstance:GetAttribute("WaveformLengthMS") -- a number attribute to represent total length of the waveform in ms

if waveformCurve and waveformCurveLengthMS then
      local floatCurve = {}
      for i, keypoint in waveformCurve.Keypoints do
            table.insert(floatCurve, FloatCurveKey.new(keypoint.Time * waveformCurveLengthMS, keypoint.Value))
      end
      hapticInstance.Type = Enum.HapticEffectType.Custom
      hapticInstance:SetWaveformKeys(floatCurve)
end

Integrate Haptics in Your UI with No Code

For your UI-based haptic use cases, you can opt for a no-code solution by using new properties HoverHaptic and ClickHaptic, available on ImageButtons and TextButtons. See documentation here.

To get started, you first need to create HapticEffect instances in your Workspace.

  1. Create a HapticEffect instance, name it as “ClickHapticEffectInstance”
  2. Go to the properties panel, change the Type to UIClick
  3. Create another HapticEffect instance, name it as “HoverHapticEffectInstance”
  4. Go to the properties panel, change the Type to UIHover

Once those are instantiated, you can apply HapticEffects to your Gui!

  1. Create a TextButton or ImageButton
  2. Go to the properties panel, navigate to the Haptic category
  3. Click the 2nd column of ClickHapticEffect properties
  4. Select the “ClickHapticEffectInstance” instance
  5. Click the 2nd column of HoverHapticEffect properties
  6. Select the “HoverHapticEffectInstance” instance

Now, at run-time, if you hover over or click the button, the designated HapticEffect will play accordingly!

FAQ

Click here to view the FAQ!

I currently use HapticService. Will my experience be affected when Haptic Effects launches in client?

TL;DR: your experience will not be affected.

We strongly recommend all Creators who are using HapticService today to try out our new HapticEffect API, since it addresses many of the bugs / inconsistencies reported about HapticService. However, we will continue to maintain HapticService for Creators who have implemented this within their experiences; we will not update HapticService and instead address inbound reports through HapticEffect.

How many haptic effects should I have within my experience?

We recommend having less than 100 simultaneous haptic effects to maintain performance quality.

:blue_heart: Made with love

Our new and improved haptics were made possible thanks to @RickleSandwich, @LittleEel0621, @cyrian_sun, and @MetaVars.

We can’t wait to hear your thoughts on our new haptics and see all the amazing things you create! Let us know about your experience and if you encounter any issues! :smile:

169 Likes

This topic was automatically opened after 10 minutes.

thank you so much for this, roblox, been cooking fr

9 Likes

My jaw dropped when I saw it finally came out. I first found out about this when I had seen the deprecated haptics service and searched for the way not to have it say deprecated.

Nice work! The predefined haptics will definitely help many people and the haptic editor thing is super handy!

Wait… does this mean there will be a bad update after this because there almost always a bad update after good.

10 Likes

My controller is already vibrating with joy.

25 Likes

Can’t wait for this to be released! This looks much simpler to use than the original HapticService, plus way more features to make games/experiences more immersive! Thank you to those who worked this! :tongue:

3 Likes

IMG_9329

Been waiting for this since the deprecation notice on the documentation. The old hapticservice was real bare and so I’m glad to see this finally reach beta.

Thanks to the team that made this a reality :pray::pray:

18 Likes

Folks. I used to pray for times like these where we’ve been so back so many times. How many times can we be so back? Because, we’re so back.

3 Likes

YESSSSSSSSSSSSS!!! Let’s GOOOOOOOOOO!!! I’ve been waiting EONS for this!

2 Likes

I love it when Roblox Studio works on making their game engine better visually.

2 Likes

Thank you Roblox! We’re so back

2 Likes

I’m trying out PressHapticEffect and HoverHapticEffect right now in Roblox Studio on an ImageButton and I can’t seem to get the assigned PressHapticEffect to play. Is this a known issue?

2 Likes

On the topic of haptics, I think support for Dualsense adaptive triggers would be sick. Might be a bit too niche to spend resources on, but it would really elevate the console experience. I’d kill for it to be a thing someday.

6 Likes

This should be working! Are you testing locally in Emulation?

1 Like

I’m testing in Roblox Studio with the beta enabled with a controller if that’s what you’re asking. The HoverHapticEffect is working as expected, but not the PressHapticEffect.

If I manually call :Play() on the assigned PressHapticEffect when the ImageButton is activated (pressed), the haptic will play like expected. Due to that, I’m led to believe that there’s a bug with PressHapticEffect.

Hello @YasuYoshida
Would you mind sending us your place file, platform information, and controller type, so we can take a closer look?

I was in the middle of reproducing the issue in a baseplate file and I think I know the root of the issue. Apparently it doesn’t work when setting StarterGui.VirtualCursorMode to Enabled.

Reproduction Place: VirtualCursorModeHapticBug.rbxl (58.6 KB)

Operating System: Windows 10 Home
Controller: PowerA Black Wired Game Controller for Xbox Series Model 1414133-01

1 Like

Awesome! I’ve been waiting for this

1 Like

Great find, thanks for the repro, we will work on the fix soon!

1 Like

This would be great to implement for Mac.

How do these haptic effects translate to GUI navigation via the trackpad?

2 Likes