Scripting Question for Gyroscope(UserInputService)

So i was bored and something hit my head,
is it possible to make a car steer using gyroscope of a mobile device?

if then how?i saw the api of gyroscope in developer.roblox.com but i dont understand it properly

so i need help pls😅

use

UserInputService:GetDeviceRotation()

that doesnt help :frowning:

I would say it is possible.
The GetDeviceRotation() Returns an inputObject and CFrame.
Assuming that, the CFrame has the rotation that you need.

All you have to do is map the X or Z rotation to the Y rotation of the wheels. I might be a good idea to use torque as change is direction is basically acceleration which is is technically another force.

If you get the device rotation every frame I am sure that it would be possible to do that. That’s very interesting. After I finish my project I might attempt that too :wink:

Yes it is. I’ve done something like that about 5 years ago.

Something not previously mentioned:
Not only can you set the turning direction using the gyroscope, but you can set the throttle aswell.

I suggest you do the testing for calibration using your mobile device. You will notice getting the right vectors will take you a while
Using getdevicerotarion(), you will get the current orientation of the device. You can then transform that orientation into a turnspeed or a velocity by taking the right vector of it
For example, one vector of it would be how up or down tilted the device is. You may use that to determine how much throttle there is. Let’s say for example: a throttle of 1 could be 0 degrees, a throttle of -1 could be 90 degrees, anything between would be somewhere between -1 and 1.

thanks guys for all your help ill try out a script and see if i can accompilsh it

1 Like