[Studio Beta] Introducing New Haptics Effects and APIs

Seems promising, but it’ll without a doubt be used wrongly :joy:

VR games when it comes to physical touches and contact with other users through vibrations, or it being overly used by Simulators or other kind of ‘stimulators’.

Are users given the option to disable haptics / haptic feedback via their ROBLOX dropdown menu? :thinking:

4 Likes

There is already a setting to disable on phone, only visible on phone though. I think any device with haptic has it.

1 Like

make sure you have haptics enabled in your roblox settings, for me it was disabled by default

Here it is, I forgot to attach image before.

I think it would be good to have a feedback thing for a down vote. Maybe downvote option could be “excessive haptics”, I do like some vibration but there will probably be a game out there using way too much haptic. I don’t want to turn on and off haptics for specific games and would like to just keep it on but games should not have too much ye.

2 Likes

Thanks for the image!
Agreed and glad there’s a way to turn it off. Obviously some games may see individual settings, but can’t count on that

1 Like

made this, used this for testing, and making my own curves

(DOWNLOAD OPTION BELOW)

I made this cause I really wanted to test every option from effectCustom.Position and effectCustom.Radius to see how they feels different and what they actually do. But I hated to having to edit the script, disable it, then enable it again just for check the effect. So yeah, I kinda just came up with this idea for test every HapticEffect.Position and HapticEffect.Radius I wanted without going through all that mess

Tested using a Robot White – Xbox Series X|S controller and this PowerA Spectra Infinity xbox series S|X

This isnt meant to work with VR or mobile devices since I feel controllers are the best option for trying out the haptic feature.

So if you’re like using a PS5 controller and its not working or whatever, just let me know. I didnt really have a way to test if it actually works on ps5, but like I think I dont need to change Enum.KeyCode or anything in UserInputService to make it work But idk lol


image
image

All the properties: radius, vector space to test a bigger area, testing out custom haptic effects, sending a vibration, or just like applying a general haptic effect, it can all be done straight from the gamepad. No need to take your hands off the controller or anything, which uhh was kinda driving me crazy cause I just could not deal with that. So yeah, thats also why I made this


.RBXL Download:
hapticX v1.1.rbxl (90.0 KB)


VIDEO

not sure if the video is gonna play, its probably better to just try it out yourself anyway

thats all. Hope this helps to understand haptic design using the new api like it did for me :cake::cherries:

14 Likes

That’s Amazing! :smiley: The link doesn’t work though, but even if it did it wouldn’t work since Roblox Studio changed/updated preventing me from launching any saved experiences on my pc.

Side note for PS5 controllers, it was a sad day (No Haptic-Feedback :frowning: ). From my experience, you can’t even control the intensity, it’s just Big Rumble Left | Small Rumble Right. Other than that, the Motors are practically in the same spot of any Controller. And PS4 is using same Rumble as Xbox.

:exclamation: Edit: The link does work, and the studio launching issue has been fixed.

1 Like

So, does this mean we’ll be getting adaptive triggers for the ps5 soon?

5 Likes

I’m having difficulty migrating my current implementation to this new system. It’s both more complex (curves, radius, & position) and more simple (HapticEffectType).

This is how I currently set things, there’s a remote event I call that passes params:

if isHapticFeedbackEnabled == true then
	HapticService:SetMotor(Enum.UserInputType.Gamepad1, whatMotorShouldBeMoving, howIntenseShouldTheRumbleBe)
	task.wait(howLongShouldTheRumbleLast)
	HapticService:SetMotor(Enum.UserInputType.Gamepad1, whatMotorShouldBeMoving, 0)
end

I’m confused about how I might target a specific motor now, not that I necessarily need to. I’m just used to how the old system worked, and it’s difficult to switch to that throughout my game. It is a different approach to haptics, so it makes sense. I guess trial and error will get me there. The GameplayCollision would be most helpful for me, as my custom character often rams into rocks to break them, though I may tweak it with Custom.

On another note, as shown in my code, I use an isHapticFeedbackEnabled variable that I set through a custom settings menu in my game. Roblox between Jan 2024 and now Roblox has released an option in the Roblox Settings Menu:

I assume Roblox internally cuts Haptics working for both this (HapticsEffects) and the HapticFeedbackService. Now, I’d assume it’d be better for performance purposes or just readability to be able to just not run my code if the player turns off Haptics. In short, I’d like a way to know if the player toggles Haptics. There’s nothing in UserGameSettings (used to tell devs user settings to an extent) or HapticService.

The introduction of the option by Roblox makes my toggle redundant, but I can’t tap into it to properly remove it.


Edit:

Here my entire code (local script under StarterGui)
-- MY custom Settings Menu Toggle: --
local UseHapticFeedback = game.Workspace.RemoteEventsFolder.UseHapticFeedback
local toggle_isHapticFeedbackEnabled_RemoteEvent = game.Workspace.RemoteEventsFolder.OptionsMenuToggles.ToggleHapticFeedbackSetting

-- Rest of the code:
local isHapticFeedbackEnabled = true
local useNewHapticEffectSystem = true -- see this: https://devforum.roblox.com/t/studio-beta-introducing-new-haptics-effects-and-apis/3606858
if useNewHapticEffectSystem then	
	UseHapticFeedback.OnClientEvent:Connect(function(whatMotorShouldBeMoving,howLongShouldTheRumbleLast,howIntenseShouldTheRumbleBe)
		local hapticEffectInstance = Instance.new("HapticEffect")
		hapticEffectInstance:Play()
		-- now I need to pass along different params for position?
		-- radius can be intensity
		-- how long can be, well, maybe looping and Play() and Stop() but should prob something else?
	end)
else 
	local HapticService = game:GetService("HapticService")
	UseHapticFeedback.OnClientEvent:Connect(function(whatMotorShouldBeMoving,howLongShouldTheRumbleLast,howIntenseShouldTheRumbleBe)
		if isHapticFeedbackEnabled == true then
			HapticService:SetMotor(Enum.UserInputType.Gamepad1, whatMotorShouldBeMoving, howIntenseShouldTheRumbleBe)
			task.wait(howLongShouldTheRumbleLast)
			HapticService:SetMotor(Enum.UserInputType.Gamepad1, whatMotorShouldBeMoving, 0)
		end

	end)
end

toggle_isHapticFeedbackEnabled_RemoteEvent.OnClientEvent:Connect(function(toggleState)
	isHapticFeedbackEnabled = toggleState
end)
3 Likes

I test it on both Xbox and Ps5 controller, the Xbox wasn’t able to navigate the UI without mouse interception although the Ps5 was but the Xbox byfar has better haptic controls. I noticed a comparable difference in the the higher rumbles compared to the lower.

The Ps5 felt like there was a difference but low rumble still felt like higher where as Xbox you can definitely feel the difference between high and low.

2 Likes

Hello @Reditect,
If you want to trigger a certain intensity with certain duration in the new form of HapticEffect, please use Custom type HapticEffect. Your code will look something like the following

if useNewHapticEffectSystem then    
	UseHapticFeedback.OnClientEvent:Connect(function(howLongShouldTheRumbleLast,howIntenseShouldTheRumbleBe)
		local waveformKeys = { FloatCurveKey.new(howLongShouldTheRumbleLast, howIntenseShouldTheRumbleBe) }
		local hapticEffectInstance = Instance.new("HapticEffect")
		hapticEffectInstance.Type = Enum.HapticEffectType.Custom
		hapticEffectInstance:SetWaveformKeys(waveformKeys)
		hapticEffectInstance.Parent = workspace
		hapticEffectInstance:Play()
	end)
else 
	...
end

Also notice that the instance you create could actually be reused and reassigned to the new intensity and duration, instead of being created every time there is an event. I will leave that to you to decide how to fit this into your experience.

Regarding the 2nd question: As of now, we don’t expose the haptics option in the User Settings, but we can look into exposing them if there is more use case around this property.

1 Like

Hello, I’ve come across these haptic effects and I really like them, but I have a few questions in mind.

  • First, is it mandatory to specify a “Parent” for the haptic effect? In other words, if we don’t set a Parent and the haptic effect’s Parent is nil, will it still work? (I don’t have a controller, so I can’t test this right now.) Additionally, after creating the haptic effect and calling “Play,” will there be a function to indicate when the vibration has ended? This would allow us to perform garbage collection and destroy the haptic effect once we’re done with it.

  • Second, Roblox provides us with various HapticEffectTypes. Where can we find the actual FloatCurveKey values for these? For example, what are the real values for something like UINotification?

local uiNotification = {
    FloatCurveKey.new(),
    FloatCurveKey.new()
    -- etc.
}

Hi! Bug report here! Every time i add the new haptic instance in any UI, it for some reason, gives error 260 “Error while receveing data, please reconnect.” I added this in one of my games, and it took the CCU to 0. This should be fixed quickly as developers may not notice it due to it not appearing on studio.

Hi @bluepear_2
The feature is currently only available for testing in Studio and isn’t supported in published experiences. Please remove the HapticEffect instances from your game and republish — that should resolve the issue. Thank you!

Ah ok! Sorry, its just that im lazy and i just read the highlights :sweat_smile: I guess i was too excited to see how it was like!

Hi @kaan650

  1. Yes, the HapticEffect instance needs parenting to work. And there is no function to indicate the ending since we would expect this to be “fire and forget”. That said we can potentially add an event that will trigger when the instance has finished playing, would that be something you are looking for?

  2. Currently, we don’t expose these values in our documentation, but we can share them in a post to help guide custom waveform design if that’s helpful.

For the first point, yes, an event that triggers when the haptic effect has finished playing is exactly what I’m looking for. This would be incredibly useful.

For the second point, sharing the FloatCurveKey values for the HapticEffectTypes in a post would be greatly appreciated. Having access to these values would significantly simplify the process of designing custom waveforms and creating our own patterns.

Additionally, I believe adding a Pause function could be beneficial for developers. Such a feature, allowing the haptic effect to be paused and resumed from where it left off, would provide greater control and flexibility in implementing haptic feedback.

1 Like

Does this mean playing 100 haptic effects at the same time or just having the instances in the data model?

100 haptic effects playing at the same time. We think that should be enough for most use cases.

Well… It wasn’t an issue. Apparently haptics aren’t on by default, which I think they should be… But i’m not sure. Thank you though.