Create motion controller out of Mobile device

Hello first of all!

I want to achieve a just dance like controller, for example you can use your mobile device as a controller to detect if you are mirroring the target character. For that I need to get the position of the mobile device accordingly relative to the ingame positions so I could easily check if the users is replicating the tagret.

I know there is :GetDeviceRotation() etc. But that only gives Vector3 of the orentation but I need the position.

Where would I start to script something like a just dancec mobile controller?

Thank you as always in advance, bye bye!

local UserInputService = game:GetService("UserInputService")
 
local gyroEnabled = UserInputService:GyroscopeEnabled()
 
if gyroEnabled then
	local inputObj, cframe = UserInputService:GetDeviceRotation()
	print("CFrame: {",cframe,"}") -- a cframe! use .Position to get the position ig. I dont know much about it.
else
	print("Cannot get device rotation because device does not have an enabled gyroscope!")
end

I personally think that you cant. You can only ig get it in VR.

This only gets the device rotation. But I need position and device rotation.

well ig i cant. cuz gyroscopes as you know can get the rotation not the position its only in VR headsets. or stuff.

https://developer.roblox.com/en-us/api-reference/function/UserInputService/GetDeviceAcceleration

Would this work combined with rotation? Can’t test it right now because I’m on mobile but it seems promising.

Or this:
https://developer.roblox.com/en-us/api-reference/function/UserInputService/GetDeviceGravity

i think if you would use the acceleration you could get a position (im taking a wild guess) but I dont exactly know how I would do that. Because I would need to somehow calibrate it and then from that point see how it moves with the acceleration.

It seems to complicated for, is there maybe a premade module for that or something?

1 Like

No clue, but I do wish you the best.