Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Is it possible to detect the movement of an android phone?

Author
Message
basicFanatic
6
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 10th Oct 2019 16:26
I think the accelerometer should be able to do this, but I can only get it to detect the rotation of the phone, not the movement.

I wanna offset a large-scale sprite, so it stays in the same world-space when I move the phone.
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 10th Oct 2019 22:10


...works as expected on my older Samsung J3. if you want other tests, please provide some code

basicFanatic
6
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 11th Oct 2019 00:16
Yeah, that was what I was using. But it seems to detect the current rotation of the phone, not its movement. Here, I use etRawAccelX() to offset a sprite:

Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 11th Oct 2019 01:31 Edited at: 11th Oct 2019 02:13
The results im receiving are miniscule and constant (even when i set my phone on the table, the numbers constantly change) but, when moving my phone, the results increase/decrease properly (in landscape, for sure, but portrait was suspect tho i didnt do real testing), including z readings).

Point is, the very small results are not going to make more than a 1-or 2-pixel change, at most (based on my arm length ) when DIRECTLY applied to sprite positions.

I dont know what ur expecting, but for any real change to the sprite positions, i'd work out some calibration and multiplier functions. I expect u could get more than simple "moving left" or right, etc, results but based on the float results i'm seeing, i doubt u'd be able to get "moved right 1 inch" accuracy unless said functions were thoroughly tested (then, accounting for constant results when absolutely NOT moving... and, i dunno how accurate we can get).

Zero movement reading:


Will be +- ~0.5-1.5 when moving

Attachments

Login to view attachments
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 11th Oct 2019 02:41
I just read some of the help files. Might b better to use the regular input commands vs raw input?

basicFanatic
6
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 11th Oct 2019 09:21 Edited at: 11th Oct 2019 09:23
Regular input commands might be the way, but I'm clueless about those too. And I kind of feel that if I can't get any movement data from the raw ones, then it just isn't there.

Here's a video showing how GetRawAccelX() are perfect for getting the current angle, not acceleration!

https://youtu.be/FmSe4waNoIQ
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 11th Oct 2019 12:29
It sounds to me like you are trying to achieve something like augmented reality but without the real world camera.
If so, them maybe the AR commands will have something for you?
https://www.appgamekit.com/documentation/Reference/Extras.htm
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 13th Oct 2019 22:35
Depending on how "large scale" you need to go, the GPS commands might be what you need. Take a look at StartGPSTracking(), and the GetRawGPSLongitude/Latitude/Altitude commands (you also need to enable the location options when exporting for GPS to work).

Login to post a reply

Server time is: 2024-04-24 04:37:04
Your offset time is: 2024-04-24 04:37:04