HapticService for Mobile devices

Can you explain what exactly you mean by abstracting away to general effect patterns? What would an example of this be?

3 Likes

I like this addition, but I would have greatly appreciated if:

  1. There was an announcement made before implementing this feature, to let us adapt our game to mobile vibrations. In fact, my games uses vibrations for controller, but the addition of this for mobile caused some inconvenience that I could have anticipated a notice was made before. For example, a user reported that music playing on the phone’s background is lowered while it’s vibrating, which is very annoying.
  2. There was a specific vibration motor enum item for mobile vibrations, or a different input type to trigger vibrations. Currently, as Phoebe said above, the vibration input type is set to Gamepad1, which is very confusing, and caused vibrations, which were intended to be felt on controller, to be on mobile as well, which is not always pertinent or even worse, disturbing.
9 Likes

E.g. instead of “SetMotor Large Left of Gamepad1 to 50%”, you would “SetEffect SmallExplosion Direction”, which then internally gets interpreted for each platform.

9 Likes

Upvote. The documentation of HapticService is poor in other ways too - vibrationvalues is not explained and it’s not clear whether :SetMotor needs to be called again to end the vibration.

5 Likes

This seems to not be working for anymore, was there any changes/updates removing this feature? This used to work in the past.

8 Likes

yeah, was trying to use this feature as well but it seems like it no longer works ? :frowning: very sad

14 Likes

It definitely works, albeit we are still on the old console API.
We want to improve this, it’s mostly a matter of priorities.

Here is how it works :

  • put a localscript on the player (this is required since this has to run on the client)
  • from that script, call HapticService:SetMotor(Enum.UserInputType.Gamepad1, Enum.VibrationMotor.Large, 1)
  • the last value is the strength, set that to 0 to disable the vibration, e.g. with a wait(0.5)

Supported platforms include everything besides Mac basically.

6 Likes

You had linked my post so I got notified (I’m not lurking in the thread :p), but I have a working demo here, it’s uncopylocked. Tried just now on my 15 pro max and it works fine:

4 Likes

Yeah, good example.
As everybody said both the API and the documentation aren’t great, since this was written for XBox controllers. Depending on the platform you get a vastly different amount of motors etc. (e.g. most android phones have 1 motor, iOS phones 2, most tablets have 0, Xbox and PS controllers are different and so on).

4 Likes

For some odd reason, @7z99’s game work, however, on my game, after ~1.5 seconds, it would stop vibrating. Anything ran from HapticService would not work. @7z99’s game works just fine, but mine doesn’t. I even went to check every script in the game that uses SetMotor, disabled it, and tested your method of this:

I used a longer wait (because I wanted to see if it would even vibrate at all), but then I realized that it would stop vibrating by itself after 1.5 seconds. Even if you were to run SetMotor again, it would not listen to it at all.

Even something like this would just not work:

RunService.RenderStepped:Connect(function()
    HapticService:SetMotor(Enum.UserInputType.Gamepad1, Enum.VibrationMotor.Large, 1)
end)

I do not know why my game is the only game affected by this glitch, or how to even fix it. The game used to have its haptics work, but now it doesn’t. Also, when I left the game, I would feel the vibration for a split second before it cutting to Roblox’s home screen.

Oh yeah, by the way

your game isn’t uncopylocked

3 Likes

After further testing, I found out having Voice Chat enabled breaks this functionality.

8 Likes

My bad it should be uncopylocked now

2 Likes

This is spamming the event every render frame, which at best doesn’t do anything after the first frame and at worst will cause bugs because it doesn’t let the motors react. These haptics motors are not running in “real time”.

I only did this because it was not running at all, assuming another script is force fully ending it, so I was experimenting on what was causing the issue

2 Likes

EDIT: Just read @Rawblocky’s post… I feel like an idiot. My friend didn’t have voice chat, so it worked. @7z99’s game didn’t have voice chat enabled, so it worked. I had voice chat enabled, so it didn’t work. Haha, silly me.

I am having this exact issue. I was testing it on my friends iPhone 13 Pro Max, and it worked great. Then I tested it on my iPhone SE 2020, and nothing happened. Tested on friends phone again, but it still works.

But when I join @7z99’s game, both work perfectly. Why?

I literally copy-and-pasted the exact script from @7z99’s game. Nothing happened. This is so mind bogglingly confusing and frustrating. Not to mention it doesn’t even work for console controllers either.

Hi, everyone. We need some advice for our project the case is - Vibration feedback does not work at some iOS versions on iPhone . Long story short - vibration feedback works as intended in our game at android platform, ps and xbox too but it does not work at iOS version 14.4 or 16. Maybe someone have any idea how to fix problem like this?

1 Like

Haptic feedback does not work for iOS 17. It works for iOS 16 though.

1 Like

Haptic feedback works great on iOS 17 for me, but there is one big problem:
Voice chat breaks haptic feedback. For some reason, when voice chat is enabled, haptic feedback just doesn’t work. This is really annoying as I want to have both in my game.

3 Likes

Same here (on android), voice chat breaks all functionality. This is super annoying because id love for every player to be able to feel some response when they click buttons or damage is applied in my game + etc…

2 Likes

Hazem, you cant have voicechat enabled in your game or else it will not work.

1 Like