HapticService for Mobile devices

I would like this for increased damage feedback on mobile

11 Likes

I would still like this feature looked into. Roblox is one of the leading free games on Apple and we should be able to use the latest API available that other games on the platform utilize, in this case Haptic Feedback.

12 Likes

I would love to see haptic feedback functionality, this would allow us to give the mobile users extra feedback, for example: I hold down on a button, my phone vibrates a little and gives me some audio feedback, the menu pops up a little bouncy and I can then use the menu. Instead of just holding on the button, a menu opens, boring.

Just like we can do this with controllers, why can’t we with phones?
User feedback is something that I think is really important, if you want a good “user interface” it’s not just about the design itself. But other stuff too. A good interface needs to be appealing to use.

Having haptic feedback would allow developers to create a more streamlined experience across all of iOS, like the homescreen icons when you hold down on them. I’m not sure if other operating systems like Android have an alternative to this.

15 Likes

Was this ever addressed? Currently looking at doing this for an FPS game that just passed 2M visity… Mobile is a little more than half our audience and haptics on mobile should really be looked at for this reason! We at LEAST need Apple device support!

17 Likes

Bumping this, kind of surprised Roblox doesn’t already have this

17 Likes

This is now supported in 538 and up.

35 Likes

It seems like mobile devices use Gamepad1 for HapticService. Can this be documented somewhere?

Seems like on my iPhone 13 Pro, all 6 VibrationMotors are supported according to IsMotorSupported, but only Large and Small seem to do anything. Are different motors supported by different devices?

6 Likes

The short answer is that the existing API is device-centric (gamepad-centric really). Calls to SetMotor Large/Small will keep working, but we are thinking about modernizing the API and extending it to more devices. Most mobile devices only have a single motor and less haptic features than iPhone 13 Pro, thus I recommend to abstract away from specific hardware to general effect patterns.

15 Likes

Thank you so much! This was one of my feature requests as an Accelerator back in the Spring of 2019 :pray:

9 Likes

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.

7 Likes

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

12 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.

4 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.

7 Likes