Built on top of Lofelt Studio SDK, Nice Vibrations is a Unity Asset which offers a universal interface to trigger HD haptic feedback on supported Unity platforms platforms at once, as well as ways to get exactly the right vibration on each platform.
Nice Vibrations provides full support for:
๐ค Android
๐ iOS haptic APIs (including iOS Core Haptics)
๐ฎ Gamepad rumble.
Nice Vibrations comes with a growing collection of royalty-free HD haptic (and audio) assets ready for quick prototyping and testing. No design skills or tasks required. The assets cover various use cases like Application UX, Game FX, Game Objects, and more.
This repository contains both the open-source code of Lofelt Studio SDK and Nice Vibrations.
๐น Play and Stop: play and stop complex HD haptic clips (.haptic files).
๐ iOS improved performance: load and play haptic clips 2x faster than on Nice Vibrations 3.9
โฐ Loop: loop a playing haptic clip.
๐ Seek: jump into any point of your haptic clip before or during playback depending on what is happening in your game.
๐ฃ Modulate Frequency or Amplitude: adjust the strength or frequency of your playing haptic clip in reaction to other on screen events (distance between characters, size of a collision), or just to create variation in the pattern playback (repetitive actions like weapon firing or footsteps and jumps).
โฑ Haptic Priority: set the priority of your haptic clip. Lower priority will be silenced if higher priority haptic clips are triggered at the same time.
๐ผ Code Only API: no need to be stuck in Unity and tied to MonoBehaviours. With the code-only API, you can work in any development environment.
๐ MonoBehaviour API: play haptics by just using the Unity Editor, without writing a single line of C# code.
โ Platform Independence: use the same C# and the same .haptic file on all platforms, no need to write platform-specific code for Android or iOS.
๐ Haptic Library: no need to design your own haptics. A growing library of haptic clips is included to get you started quickly and with limited experience.
๐ Global Haptic Level and Mute: disable haptics entirely with one switch or reduce the intensity of haptics across the whole application.
๐ Fully Featured Demos: demos included to help you learn how to apply all of the features for your specific use case. These demos will also help you see how to migrate your existing Nice Vibrations code to the new APIโs.
๐ Haptic Presets Support: trigger 9 predefined haptic patterns with a single line of code.
๐ณ Gamepad Rumble: play .haptic files on gamepads supported by Unity.
โ Fallback Support: play basic haptics on older phones and operating systems.
And more..
The Nice Vibrations documentation is available in this repository's Wiki. It explains how to integrate and use Nice Vibrations with new or existing Unity projects. It also contains documentation for the Lofelt SDK for iOS and Android.
Nice Vibrations depends on the cross-platform Lofelt Studio SDK. This means that the Lofelt Studio SDK needs to be build first in order to use Nice Vibrations on Unity.
Currently, all the steps below were tested using a macOS environment. Windows steps are not provided at the moment โ๏ธ.
However, Windows support is available if iOS build support is not required. You just need to skip the steps required for the macOS/iOS builds and edit the build scripts according to your needs.
To develop, build and run the Lofelt SDK there are the following requirements:
clippy
and rustfmt
components are included, which is the
default when installing via rustup
Install
rusty-hook
cargo install rusty-hook
rusty-hook init
The Rust core library itself does not generate haptics, for that the Android library or iOS framework needs to be used. The Rust core library however has unit tests that can be run, so it can make sense to work on it without any interfaces.
To develop, build and run Nice Vibrations there are the following requirements:
brew install doxygen
The source code of Nice Vibrations can be found in the interfaces/unity/NiceVibrations Unity project.
Once the development environment is setup as specified in Setting up the Development Environment section building the Nice Vibrations asset is possible by using one script:
sh build.sh
โ ๏ธ This script will cross-compile Lofelt SDK for iOS and Android, but won't cross-compile the Unity Editor Plugin host. This means that if you're on macOS, the Unity Editor plugin host will only build the shared library for macOS. To build for Windows, you need to run
sh build.sh
in a Windows computer. Alternative you can use a release package available in this page.
Running this script will take more than a couple of minutes, depending on your machine. Meanwhile, have some coffee โ or tea ๐ต.
Once its finished,a nice-vibrations-asset
folder is created which contains the
NiceVibrations asset.
The NiceVibrations folder can then be imported into a Unity project:
๐ You're now ready to use Nice Vibrations ๐.
Have a look at the Nice Vibrations API documentation, available in interfaces/unity/doxygen/html/index.html to know more.
If you would like to change the Nice Vibrations Unity asset code, check this section for more information.
If you're not using Unity and just need the iOS Framework or Android library, check the steps below.
To build for iOS (after doing the setup for iOS):
sh build-platform.sh ios
To build for Android (after doing the setup for Android):
sh build-platform.sh android
To build the SDK for iOS and Android for distribution:
sh release-sdk.sh
To build the lofelt-sdk Rust core library:
cargo build
The available binaries of the static library are located in `target/