Using Wwise, you can manage motion using the same feature set that you use to manage the audio in your game. This means that everything that you used to do to audio data can now be done to motion data using the same API. Currently, only the console game controllers are supported in the motion engine.
|
Note: Motion is not available on the Mac® and iOS, tvOS platforms. |
The motion devices are not available by default in the sound engine. The game must link to the separate library for each of the devices. See the following table:
Device | Library | ID | Callback |
Game Controller | AkRumble.lib | AKMOTIONDEVICEID_RUMBLE | AkCreateRumblePlugin |
Device | Library | ID | Callback |
Game Controller | AkRumble.lib Xinput.lib dinput8.lib |
AKMOTIONDEVICEID_RUMBLE | AkCreateRumblePlugin |
The game must register the device in the Motion engine by calling AK::MotionEngine::RegisterMotionDevice. You need to make this call once for each device type used in your game. If your game supports multiple devices but the particular hardware setup it runs on doesn’t have them installed, you should avoid registering the device uselessly. This is not the way to test if the device is installed or not.
The Motion engine supports multiple players and multiple devices per player as well. For example, an Xbox360 game with a split-screen can have up to 4 players on the same console. The game must register each player so that they can receive feedback through each of their devices. This is done with: AK::MotionEngine::AddPlayerMotionDevice.
This must be repeated for each player and device currently connected. If the device driver is not installed on the computer this will return an error. It won’t check if the devices are actually powered. For Rumble, checking if the controller is connected should be done by the game, when the input device is initialized.
On the game consoles, the game controllers can be disconnected either physically or through communication problems. It won’t have any adverse effects on the Motion engine other than using some resources uselessly. If you think a device is disconnected for a long period of time you can call AK::MotionEngine::RemovePlayerMotionDevice to free up resources.
If a player disconnects his controller and reconnects it in a different port of the console you must call RemovePlayerMotionDevice and then AddPlayerMotionDevice with the new player port.
Since each of the players, in a multi-player game, won’t be doing the same thing at the same time, the feedback received shouldn’t be the same either. To control which player receives which motion effect, the same concepts used in audio have been reused: the listener and the game object. For motion, the game object “emits” vibrations and the listener “receives” them.
In a game with motion support, each player must have its own Listener (see Integrating Listeners). The game must assign a listener to a player explicitly. This is done with AK::MotionEngine::SetPlayerListener.
Note that by default all players use listener 0. The Listeners have been modified to act as receivers for both audio and motion data. However, the listeners are only enabled to receive audio by default. To specify what kind of data the listener will receive, call AK::SoundEngine::SetListenerPipeline.
After this is setup, the game only has to activate the proper listeners' bits on each game object, depending on the situation. This is done the same way it is for audio, using AK::SoundEngine::SetActiveListeners.
However, there is one major difference with audio. In audio, the listeners come into play only when a sound is set with 3D positioning. This is not the case with motion. For Motion, the listener and game object setup is mandatory for any feedback to be felt in the motion devices.
Wwise currently ships with the following motion source plug-ins:
Name | Library | ID (AKSOURCEID_...) | Callback | Devices |
Motion Generator | AkMotionGenerator | _MOTIONGENERATOR | AkCreateMotionGenerator | Game Controllers |
To use a motion source plugin, just register it as you would any other source plugin, with AK::SoundEngine::RegisterSource.
Writing source plugins for motion devices is very similar to writing plugins for audio. Refer to the section for audio plugins for more details (Audio Plug-ins).
There are two differences between audio and motion source plugins. First, the interface AK::Wwise::IMotionSourcePlugin must be supported by the plugin. It derives from AK::Wwise::IAudioPlugin, therefore all services and restrictions related to audio plugins apply (see Writing the Wwise Part of an Audio Plug-in). The second difference is in the xml file needed to define the plugin properties. Although most of the file is identical to what is needed for regular audio sources (see Wwise Plug-in XML Description Files), the motion plugin must be declared as follows:
<FeedbackSourcePlugin Name="Wwise Motion Generator" CompanyID="0" PluginID="405" DataType="TypeSpeedSamples">
So, in order for a specific player to receive motion with one device you must:
In your Wwise project:
If the motion created in Wwise is not playing on a particular motion device, you can troubleshoot the problem using the Profiler. To capture motion data in the Advanced Profiler, do the following:
Now you can connect to your game and profile the motion to identify the potential problem. The "Motion Devices" tab contains two separate lists: one for Devices and one for Game Objects. The Devices list indicates which motion devices have been properly registered and initialized in the sound engine, for each player.
To troubleshoot the problem, first check to see if the motion devices have been properly initialized, by doing the following:
If the motion device appears in the list, then check to see if the motion device has been associated with a particular player, by verifying that there is a check mark matching up the device to the appropriate player. If there is no check mark, then either of the following may be true:
If the motion devices have been properly initialized and they are associated to the appropriate player, then you can check the Game Objects list to verify if the game objects are setup properly to send motion data to a specific player. If there is no check mark for a particular combination of game object/player, you can switch to the Listeners tab of the Advanced Profiler to check the following:
Des questions ? Des problèmes ? Besoin de plus d'informations ? Contactez-nous, nous pouvons vous aider !
Visitez notre page d'AideEnregistrez votre projet et nous vous aiderons à démarrer sans aucune obligation !
Partir du bon pied avec Wwise