What’s this? #
Motion recognizer is a component that recognizes device movements. It is still in the experimental stage, and many improvements are still required.
How to enable Motion Recognizer? #
Go to Project Settings > Plugins > Touch Interface and in the Motion Recognizer category, check the Enable Motion Recognizer setting. Then you just need to add the Motion Recognizer component on a class where you want to bind a function to a device motion.
Motion Recognizer Component Settings #
Input
- Auto Receive Input : Automatically registers this actor to receive input from a player (Gyroscope data).
Quick Acceleration
Detects rapid movement of the device. A simple tab can be enough to trigger the event.
- Quick Acceleration Threshold : Min acceleration value needed to trigger Quick Acceleration event.
- Delay Between Quick Acc Detection : Delay between quick acceleration detection. Avoids multiple detections in one direction.
Shake
Detects when the device is shaken by the user.
- Shake Detection Threshold : Min acceleration value needed to trigger shake event.
- Shake Allowed Time : Shake detection time. e.g. If acceleration to the right is detected, acceleration to the left must be detected within the allotted time.
- Call Shake Each Frame : If enabled, when shaking is detected, On Shaking event is called each frame. If disabled, On Shaking is only called when quick acceleration is detected.
Motion Based Rotation
Use device movements to control the camera.
- Turn Rate : Rotation speed.
- Invert Axis : Invert axis.
- Limit Rotation : Whether or not camera rotation should be limited.
- Max Amplitude : Max angle for rotation limiter.
How to get device motion events? #
In the events part of the component, you just have to click on the event you want to retrieve. You can bind/unbind a function too if you want.
What device motion events are recognized? #
The current algorithm in v2024.1 is able to recognize the following device motion :
- On Quick Acceleration : Called when quick acceleration is detected.
- On Shake Start : Called when shake is detected.
- On Shaking : Called every time the direction changes. Can be called each tick.
- On Shake End : Called when shake is ended.
- On Motion Based Rotation : Control camera view with gyroscope. X=Roll, Y=Pitch, Z=Yaw