Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

[RELEASED] Nice Vibrations : add haptic feedback and vibrations to your game in a single line

Discussion in 'Assets and Asset Store' started by reuno, Feb 18, 2018.

  1. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
    I'm happy to present Nice Vibrations, a simple yet powerful solution to add vibrations and haptic feedbacks to your games. Built on top of the native iOS and Android APIs, it offers a universal interface to target both platforms at once, as well as ways to get exactly the right vibration on each platform specifically. It's a proven and battle tested solution that just gets the job done.

    upload_2018-2-18_12-49-21.png

    Nice Vibrations comes with universal methods (that will target both iOS and Android in one line), or specific ones to get more tailored results on each platform. It's super easy to install (you just need to import the package), and very easy to work with. All methods are one liners, and you don't even need to add anything to your scenes.
    • Trigger vibrations on your device in one line of code
    • Lots of variations : from simple vibration, to complex, amplitude based patterns, everything's that's allowed by iOS or Android hardware is possible.
    • Complete API documentation and tutorials
    • Demo Scene with 9 presets to play with on iOS or Android
    • iOS and Android interfaces
    • Support for iOS Taptic Engine
    • Android pre-SDK 26 support
    • Android support for the new (post SDK 26) VibrationEffects
    • Universal methods that allow support for both targets in one liners
    • Fully commented code
    You can give it a try by downloading the free demo on Google Play.
    I had an iOS demo ready (which also happens to be even better than the Android one due to the better haptic hardware on iPhones), but it got rejected by Apple, who apparently (and understandably) don't want demos on their store. But you can download my latest game, Rugby Bots, for free on the App Store. It uses a few of the available haptics, and you'll get an idea of how it feels.

    For more info about Nice Vibrations, check out the dedicated website.
     
    Last edited: Feb 21, 2018
    LunaD03 and Mauri like this.
  2. Trisibo

    Trisibo

    Joined:
    Nov 1, 2010
    Posts:
    233
    Hi, I downloaded the Rugby Bots game on my iPhone 6s (latest iOS version), but I'm not getting any vibrations. I'm assuming it uses a previous version of the plugin that didn't fallback to regular vibrations in the absence of haptics functionality in the device, and it has been fixed in the latest version of the plugin, is that so?
     
  3. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
    @DED-Games > Haptic feedbacks aren't available on iPhone 6S. They were introduced by Apple on the iPhone 7 (and subsequent phones). I could have triggered basic vibrations as a fallback but they just don't feel very nice on "old" phones.
     
  4. Trisibo

    Trisibo

    Joined:
    Nov 1, 2010
    Posts:
    233
    I thought it did fall back, since somebody in an Asset Store review talked about the iPhone SE and you mentioned having updated the plugin to solve the issue. :( I really think allowing normal vibrations when possible (while knowing the limitations) would be useful for the plugin.
     
  5. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
    @DED-Games > Oh but it should fallback with 1.2! That's indeed the major change in the latest update.
    I just meant I had prevented that fallback in Rugby Bots because it would have been too much for my taste.
    What version of Nice Vibrations are you running? You can check that in the readme file.
     
  6. Trisibo

    Trisibo

    Joined:
    Nov 1, 2010
    Posts:
    233
    Ahhh, I see, I thought you were talking about the plugin. I haven't got it yet, I was just testing the demo/game, I'll definitely get it. Thanks!
     
  7. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
    @DED-Games > Alright, don't hesitate to let me know if you run into trouble :)
     
  8. hahahpizza

    hahahpizza

    Joined:
    Sep 9, 2015
    Posts:
    11
    Hey, have anyone tried it on 6S?
     
  9. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
    @cl0n > It won't work, it only supports devices that have haptic feedback support. On a 6S it'll revert to regular vibrations.
     
  10. mahmud91

    mahmud91

    Joined:
    Nov 12, 2015
    Posts:
    1
    hey @reuno i've been using your plugin. how can i stop the vibration in iphone 6s and older phones? i only love to have the haptic feedbacks to the new phones.
     
  11. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
    @mahmud91 > As explained in the documentation, there's a bool HapticsSupported() method you can use to test for that :)
     
  12. DearUnityPleaseAddSerializableDictionaries

    DearUnityPleaseAddSerializableDictionaries

    Joined:
    Sep 12, 2014
    Posts:
    135
    Edit: Nice stuff! Glad to see the HapticsSupported method, edited out my comment as it asked for that method.
     
  13. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
    @EGA > I was about to answer just that, you beat me to it :)
     
  14. yomanx

    yomanx

    Joined:
    Dec 5, 2016
    Posts:
    38
    But what about taptic engine in iphone 6S?
     
  15. Trisibo

    Trisibo

    Joined:
    Nov 1, 2010
    Posts:
    233
    Apple didn't open the API for that model, in theory only Apple can use it.
     
    reuno likes this.
  16. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
    @yomanx > I would add to what @DED-Games wrote that trying to access it (there are ways to do so) can get you kicked from the app store, so do that at your own risk.
     
    yomanx likes this.
  17. yomanx

    yomanx

    Joined:
    Dec 5, 2016
    Posts:
    38
    As i see a lot of popular games use it in 6s. Latest one "Amaze!" when the ball touches the walls we can feel it.. or maybe it's vibration.. but doesn't look like normal vibrations.

    Tested yours Rugby Bots - really funny game)) but i can't feel haptics that's what I need. I saw in game "flip rush" haptic effect when you touch booster on the map and not sure if can i do it with your plugin.
     

    Attached Files:

  18. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
    @yomanx > As I said, it's doable, just not something I'd recommend doing.
     
    yomanx likes this.
  19. breban1

    breban1

    Joined:
    Jun 7, 2016
    Posts:
    194
    Hi, great asset thanks!

    A few questions:

    Android
    Is it possible to check if device has vibrator? According to android docs: https://developer.android.com/reference/android/os/Vibrator

    abstract boolean hasVibrator()
    Check whether the hardware has a vibrator.

    iOS
    Shouldn't the function HapticsSupported() check for iPod/iPad? Or is that considered with different phone models?

    Example:
    Code (csharp):
    1.  
    2. public static bool HapticsSupported()
    3. {
    4.      bool hapticsSupported = false;
    5.      #if UNITY_IOS
    6.      DeviceGeneration generation = Device.generation;
    7.      if ((generation == DeviceGeneration.iPad2Gen)
    8.      || (generation == DeviceGeneration.iPad3Gen)
    9.      || (generation == DeviceGeneration.iPadMini3Gen)
    10.  
    etc.
     
  20. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
    @breban1 > Unfortuntately hasVibrator doesn't tell you if haptic feedbacks are supported, and will return true on pretty much every phone on the market. And HapticsSupported already checks for iPads and iPods :)
    Edit : actually I'm one update in the future, sorry. The HapticsSupported list got greatly improved recently, and that will be included in the next release (coming soon).
     
  21. breban1

    breban1

    Joined:
    Jun 7, 2016
    Posts:
    194
    Thanks for the quick reply! (not expected, especially on weekends AND a holiday no less!)

    There are a ton of Android tablets that don't have vibrate, I own a few of them for testing. Is that function available, or does it not work? Any idea?

    Sorry, I missed the iPods! But Nice Vibrations v1.5 doesn't include iPad.
    Here's the full check I have from the latest release

    DeviceGeneration generation = Device.generation;
    if ((generation == DeviceGeneration.iPhone3G)
    || (generation == DeviceGeneration.iPhone3GS)
    || (generation == DeviceGeneration.iPodTouch1Gen)
    || (generation == DeviceGeneration.iPodTouch2Gen)
    || (generation == DeviceGeneration.iPodTouch3Gen)
    || (generation == DeviceGeneration.iPodTouch4Gen)
    || (generation == DeviceGeneration.iPhone4)
    || (generation == DeviceGeneration.iPhone4S)
    || (generation == DeviceGeneration.iPhone5)
    || (generation == DeviceGeneration.iPhone5C)
    || (generation == DeviceGeneration.iPhone5S)
    || (generation == DeviceGeneration.iPhone6)
    || (generation == DeviceGeneration.iPhone6Plus)
    || (generation == DeviceGeneration.iPhone6S)
    || (generation == DeviceGeneration.iPhone6SPlus))
    {
     
  22. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
    @breban1 > I've just pushed v1.6 of the asset, it'll fix the supported device list, and also improves the way defaulting to regular vibrations works.
    In my experience that function is poorly implemented by manufacturers on Android's side, unfortunately.
     
  23. breban1

    breban1

    Joined:
    Jun 7, 2016
    Posts:
    194
    Sounds good! Thanks for the info and the great asset/support!
     
  24. PandaArcade

    PandaArcade

    Joined:
    Jan 2, 2017
    Posts:
    119
    Hi @reuno, I have been implementing Nice Vibrations to try in our game and I have some questions and comments.

    1. When setting rumble why do you use intensity for the low-frequency motor and sharpness for the high-frequency motor?
    rider64_ZIqOGVMQih.png
    Shouldn't it be something more like this...
    Code (csharp):
    1. var lowFrequency = intensity * (1f - sharpness);
    2. var highFrequency = intensity * sharpness;
    3. MMNVRumble.RumbleContinuous(lowFrequency, highFrequency, controllerID);
    2. It seems as though iOS doesn't support continuous haptics longer than ~35 seconds. Is this mentions in the Nice Vibrations documentation? I didn't see it and implemented a solution that didn't work because of this limitation.

    3. Wow, some of your methods have A LOT of parameters! It would be nice to have some more overloads so that if I only want to deal with one platform or just gamepads I don't have to define several null/default parameters. I could bypass these parameter heavy methods and call the methods they call, but then I would have to reimplement some of their logic, which is not ideal.

    4. It would be nice to have methods to generate AHAP files based on an AudioClip or a couple of animation curves. Having to author them using the website you linked in your documentation is very tedious.

    Thanks for reading :D
     

    Attached Files:

    Last edited: Aug 13, 2020
  25. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
    @PandaArcade > Thanks for your feedback, and for still using the forum in 2020, I had forgotten about that thread :)

    1. At this point there's so much difference between a phone motor and a gamepad motor (and so much difference between gamepads) that I see these (in the specific context of that call) as just arbitrary values, used for consistency across universal calls - and to avoid adding two extra parameters, see (3). I'll definitely give these conversion lines of yours a try though, but I have to admit I never considered actually converting intensity and sharpness into low/high frequency, never seen these as something on the same "scale".

    2. There's no limit on NV's side. There are hardware limits though, that as far as I know vary from device to device, and Apple recommends way shorter continuous than 35 seconds. Never seen it written in stone, but that'll pop in reviews. 35s is bound to burn phones. And no, NV's documentation doesn't mention that limit, it's on Apple's end, like all their other rules. Unfortunately they don't officially communicate on them, and how they apply them often varies from studio to studio, so I can't really just write in the documentation what gets reported to me, as it's not official or stable in time.

    3. The methods with a lot of parameters are the ones that are universal, in that they'll target iOS, Android, gamepads, etc. Can't think of a way to remove parameters from these. The individual methods have as few parameters as possible. If you want to deal with just gamepads, there are already methods for that. I'm open to suggestions though!

    4. I've considered the animation curve solution, but it's just not enough to describe AHAP files. There are many other solutions to create AHAP files, feel free to pick the one you prefer! There are also apps, other websites, etc. The ones in the documentation were just suggestions. Most studios I talk to about NV seem to have their own internal pipelines for AHAP production these days.

    Edit : forgot to say that Pico Tanks is ❤️
     
    Last edited: Aug 13, 2020
    PandaArcade likes this.
  26. PandaArcade

    PandaArcade

    Joined:
    Jan 2, 2017
    Posts:
    119
    Thanks for the reply ❤️
    Oh sorry, I didn't see the methods for dealing with just gamepads :)
    I had a look at a AHAP file, I didn't see anything you couldn't describe with two animation curves and a couple of additional parameters.
     
  27. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
    @PandaArcade > You're right, with two animation curves, additional remap parameters, you can get closer to something that'd let you describe an AHAP file. I'm not sure it'd be as easy to use as any of the alternatives out there though :)
     
    PandaArcade likes this.
  28. PandaArcade

    PandaArcade

    Joined:
    Jan 2, 2017
    Posts:
    119
    Lars-Steenhoff and reuno like this.
  29. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
    @PandaArcade > No, not at the moment. As you can see on that page you linked, this is still a beta feature, only available on iOS 14. That API is still likely to change, and undocumented. Once it's out and stable, I'll add it to Nice Vibrations.
     
    PandaArcade likes this.
  30. PandaArcade

    PandaArcade

    Joined:
    Jan 2, 2017
    Posts:
    119
    Awesome! We haven't released our games update with haptic feedback and players are already asking for gamepad rumble :rolleyes:
     
    reuno likes this.
  31. skyfancy

    skyfancy

    Joined:
    Jan 25, 2014
    Posts:
    4
    MMNViOS.iOSTriggerHaptics also dosen't work on 6s, I'm confused :confused:
     
  32. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
    @skyfancy > As I said in the reply you're quoting, there's no haptic engine in an iPhone 6S. So of course haptics don't work on it :)
     
  33. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,449
    Looking forward to this too :)
     
    reuno likes this.
  34. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,281
    Hey, we're having some issue building our game using Nice Vibrations 3.8.
    We need to support iOS, macOS and tvOS.

    When building on tvOS, xcode fails with this error:

    Code (CSharp):
    1. NiceVibrations/Common/Plugins/iOS/Swift/MMNViOSCoreHapticsInterface.swift:3:8: No such module 'UnityFramework_NiceVibrationsPrivate'
    nice_vibrations.png

    Any ideas how to fix?
    We don't really require haptics on tvOS, although it would be nice to have.
     
    wavs likes this.
  35. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
    @CDF > It looks like something in your project is messing with your xcode settings. Have you tried creating a new, empty project, importing only NV, and building the demo? What's the outcome of that?
    If your issue persists, please use the support form and provide more context info about your project, I'll be happy to help.
     
  36. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,281
    The build still fails to compile in xcode using the Demo project as well.
    We fixed by disabling tvOS in the supported plugin platforms:
    disable_haptics.png
     
  37. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
    @CDF > That's strange, I don't reproduce the problem. I'll investigate, thanks for mentioning this!
     
  38. fechy

    fechy

    Joined:
    Jan 12, 2019
    Posts:
    10
    @reuno > I'm also getting this issue building the IOS project. However, we do not support TvOS.
    Can we get an official solution for this?
     
  39. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
    @fechy > Have you tried creating a new, empty project, importing only NV, and building the demo? What's the outcome of that? I'd love to offer an "official solution" to that, but I'd need to be able to reproduce the problem. So far only a handful of people seem to have run into the issue, it just works for most people, and I never got any significant info that could help identify the problem. If it persists for you, don't hesitate to send exact context info and repro steps via the support form.
     
  40. XxPleYxX

    XxPleYxX

    Joined:
    Jul 26, 2011
    Posts:
    41
    I think I have detected the error, it occurs when you move the Feel folder inside another folder, in my case Third Party
     
  41. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
  42. BigRedGames

    BigRedGames

    Joined:
    Jun 25, 2016
    Posts:
    48
    I was having the same issue. I fixed it by updating to the last version of the plugin.
     
    reuno likes this.
  43. BigRedGames

    BigRedGames

    Joined:
    Jun 25, 2016
    Posts:
    48
    The problem is still happening @reuno . The hack to solve this problem is to move the plugin folder to inside of another folder and move back to Assets, but I have a build script and It is very annoying. Do you have a proper solution for this problem?
     
  44. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
    @BigRedGames > If you click on the link above your posts, you'll read about the MMNVPathDefinition that lets you update paths to the header and module, hopefully that'll solve your issue.
     
  45. BigRedGames

    BigRedGames

    Joined:
    Jun 25, 2016
    Posts:
    48
    Ok I will try that. Thanks Reuno.
     
    reuno likes this.
  46. BigRedGames

    BigRedGames

    Joined:
    Jun 25, 2016
    Posts:
    48
    @reuno I tried all the recommendations described on the documentation, but it is still showing the same error when I try to build to iOS. The only solution as I said is to move the NiceVibration folder to another folder and back to root and restart the build. If you need more details please ask me.
     
    Last edited: Nov 12, 2021
  47. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
    @BigRedGames > Yes, I'd need more info, as I don't reproduce the issue. Don't hesitate to use the support form and provide the info requested right next to it, as well as exact steps to reproduce.
     
  48. kureysalp

    kureysalp

    Joined:
    Oct 1, 2017
    Posts:
    10
    We are using a template project in our team and using that asset for 6+ months and suddenly I got same error in a random project that nothing changed in plugins or any other core files. I can't build Xcode Project.
     
  49. reuno

    reuno

    Joined:
    Sep 22, 2014
    Posts:
    4,870
    @kureysalp > Things rarely break on their own, I'd recommend rolling back to a previous commit if you can, and check if the issue persists. Something must have changed.
     
  50. BigRedGames

    BigRedGames

    Joined:
    Jun 25, 2016
    Posts:
    48
    I downloaded the new version from Lofelt that has documentation saying that they solved this issue. I'm trying this one if this solves the problem I will post here.