Discuss Scratch

whitesquare
Scratcher
7 posts

Accelerometer/gyroscope sensor

Hi,

Mobile devices have a bunch of sensors, including an accelerometer which allows you to tell the orientation of the device with fairly good precision.
All those sensors are exposed via Javascript nowadays, and the interface is relatively straightforward (see https://developer.mozilla.org/en-US/docs/Web/API/Sensor_APIs). There are also higher-level sensors that are just as useful if not more, such as the orienation sensors (combining accelerometer, gyroscope, and optionally magnetometery, to give a quaternion representing the orientation of the device)

This is particularly interesting in my opinion as it can be turned into quite a convenient input for those devices. One can imagine using it to make a Scratch game like Marble Madness or any other sort of game needing analog input control. If an orientation sensor was available, I would try and use it as an alternative input controller instead of the mouse for my last game (https://scratch.mit.edu/projects/405856691/), where mouse-driven control is not really convenient on mobile devices (it works, but the user's hand keeps getting in the way of the screen). I know I could find better ways to make existing inputs work on mobile devices, but from experience playing other mobile games, those sensors can make for a very intuitive input device.

What are the chances of getting it added as a Scratch sensor?

Thanks,
A.
Botcho_Otkho
Scratcher
1000+ posts

Accelerometer/gyroscope sensor

Should the project show a warning like it does for the
username
block?
Like “This project uses Accelerometer/Gyroscope sensors, so that the entire project or a part of it is only usable on mobile devices.”.
whitesquare
Scratcher
7 posts

Accelerometer/gyroscope sensor

This project uses Accelerometer/Gyroscope sensors, so that the entire project or a part of it is only usable on mobile devices.

I don't think it has to be an either/or. Just like projects may use keyboard, mouse and touchscreen all at once, there's no reason they couldn't use accelerometer/gyro if it's there (in addition to any other input), and just ignore if it's not. So it would not be restricting the project to mobile devices, but make it potentially more accessible on those. It would not take anything away from computer users.
Botcho_Otkho
Scratcher
1000+ posts

Accelerometer/gyroscope sensor

whitesquare wrote:

This project uses Accelerometer/Gyroscope sensors, so that the entire project or a part of it is only usable on mobile devices.

I don't think it has to be an either/or. Just like projects may use keyboard, mouse and touchscreen all at once, there's no reason they couldn't use accelerometer/gyro if it's there (in addition to any other input), and just ignore if it's not. So it would not be restricting the project to mobile devices, but make it potentially more accessible on those. It would not take anything away from computer users.
How? Generally, computers have no motion sensors (I think some of them do, but they should be really rare.)
whitesquare
Scratcher
7 posts

Accelerometer/gyroscope sensor

I don't really understand your question. What's the issue here?

To take a different perspective, most mobile devices don't have keyboards, yet you can use “key pressed” blocks in a project. That doesn't make it necessarily unusable on a mobile device (it can use an alternative form of inputs as well), and scratch doesn't need to display a “keyboard sensor” warning. It's the same thing here. If the computer/device doesn't have the accelerometer/gyro sensor, the sensor can simply return a zero value or some other constant, just you're able to get a “mouse x/y” position on a mobile devices even when there's no finger on the screen.

In the end, it's down to the author to decide which input methods the project will use. If I have access to both mouse sensors and gyro sensors, I can make a project that can be user-friendly on both an old-school computer and a mobile device. If someone decides to *only* use the gyro, then that makes their project inaccessible on a computer, much like a project *only* using the keyboard would be inaccessible on a mobile device. If you feel a warning should be displayed for those kinds of projects, I see your point, but that's a wider issue/request than just this sensor specifically.

Powered by DjangoBB