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)