-
Notifications
You must be signed in to change notification settings - Fork 0
๐ฏ Tutorial: Basic Gyro Aim Implementation
This guide covers how to enable and apply gyroscope data to control the camera using the controller sensors.
Before receiving any sensor data, the gyroscope must be initialized.
- On the BeginPlay event, call the EnableGyroscopeValues node from your
SonyGamepadSensorsProxy. - Set the target
ControllerId(default is 0) and ensurebEnableGyroscopeis set totrue.
It is standard practice to allow the player to reset the camera and pause the gyro input to reposition their hands physically.
- Create an input action for resetting (e.g.,
IA_Gyro_Reset). - On the Started trigger, set a
ResetGyroboolean totrueand call the ResetGyroOrientation function. - On the Completed trigger, set the
ResetGyroboolean back tofalse.
Use the continuous vector data from the gyroscope to drive the camera.
- On the Triggered pin of your
IA_Gyroinput action, store the action value into a local variable (e.g.,LastVectorGyro). - Add a Branch node to verify that the Not_PreBool of your
ResetGyrovariable is true (meaning the player is not currently holding the reset button). - Pitch (Up/Down): Extract the Y-axis from the gyro vector, negate the float (using NegateFloat), and connect it to the AddControllerPitchInput node.
- Yaw (Left/Right): Extract the Z-axis from the gyro vector and connect it directly to the AddControllerYawInput node.
If your project requires raw physical data, whether for UI debug information or procedural animations:
- Map
IA_Accelto capture and store the accelerometer vector. - Map
IA_Inclinationto capture and store the device's tilt/inclination vector.
To speed up your implementation, you can review the functional setup by downloading the demo project.
When downloading the project, you will find the assets following this exact directory structure:
-
Character and Code:
/Content/InfimaGames/FreeFPSTemplate/Core/BP_Character.BP_Character -
Input Actions:
/Content/InfimaGames/FreeFPSTemplate/Data/Sensors
This tutorial project uses parts of the material https://www.fab.com/listings/6a0af880... created by Infima Games, which is licensed under the Creative Commons Attribution 4.0 International license. The original material has been modified to integrate gyroscope rotation reading.
Important/Additional Notes: Includes the "Low-Poly AAC Honey Badger" model (https://skfb.ly/6SMsu) by TastyTony which is licensed under Creative Commons Attribution (http://creativecommons.org/licenses/b....
Requires Blender version 4.0.2 or higher, can be downloaded here