Can I code motion controlls?

Is there any way I can code my game so mobile players can use the gyroscope in their phone to control stuff like maybe a ball rolling or the camera?

It would be even cooler if they could do that with a controller like a vr controller, joy-con, wiimote, psmove, etc. but even though that would be better it’s probably harder and less possible.

Thanks for the help everyone!

2 Likes

Im not too sure about controllers allowing this based on my research but I know gyroscope and Accelerometer sensors on mobile/tablet devices but this is not yet supported by Roblox.

So the ball game is possible.

1 Like

A few weeks ago, I actually thought about doing something like this. I wanted to make some game where the player would have to get a ball through a maze by tilting the phone.

I kind of got bored and stopped after like 10 minutes lol.

local uis = game:GetService("UserInputService")


while true do
	if uis.GyroscopeEnabled then
		local _, gyroCf = uis:GetDeviceRotation()
		workspace.testPart.CFrame = gyroCf
	else
		warn("No gyroscope was found.")
		return
	end
	wait()
end
1 Like

Wait, I’m confused, are you saying that phone motion controls are possible and controllers are not? Or none are posible?

1 Like

Cool! can I use that part of your script?

1 Like

I want to finish this code but don’t know how. Where do I put it in explorer?

1 Like

some of the axis is somewhat switched or flipped???

1 Like