Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: shamo on February 27, 2018, 09:46:10 PM

Title: tilt functions on android devices
Post by: shamo on February 27, 2018, 09:46:10 PM
Hi all,
How does one go about implementing the tilt functions (gyro I think?) from your Android device to translate into character movement etc? I have a rough idea of putting it into action, but don't know how to call if from the device.
Thanks
Title: Re: tilt functions on android devices
Post by: djaydino on February 28, 2018, 01:49:45 AM
Hi.
I believe you can use "Get Device Roll" action.
Title: Re: tilt functions on android devices
Post by: shamo on February 28, 2018, 02:38:56 AM
Thanks Djay, just found all the 'Device' settings...can't believe I didn't see them before. Nothing came up in the searches with the words I thought would match!
Will se how I go with these.
Title: Re: tilt functions on android devices
Post by: shamo on February 28, 2018, 05:10:50 AM
The Device roll works a treat, but can't seem to get any results from the 'Get device Gyroscope' Any suggestions? Should the 'device' be set to default (user owner) or something else?
Title: Re: tilt functions on android devices
Post by: shamo on March 02, 2018, 05:15:49 PM
Anyone been able to implement the 'Get Gyroscope' on Android?
Title: Re: tilt functions on android devices
Post by: djaydino on March 03, 2018, 12:46:59 PM
Hi,
Have you tested with a build on an android device that has gyro?

I don't think you can test this when using editor.
Title: Re: tilt functions on android devices
Post by: shamo on March 03, 2018, 06:29:35 PM
Hi, yes testing on my HTC phone, which from what I've read uses a gyro. It has no problem running apps like a spirit level.
Title: Re: tilt functions on android devices
Post by: djaydino on March 04, 2018, 08:25:30 AM
Hi.
I tested the action and indeed it does not work,
So i went in the script and i think this never even worked.
So i rebuild the action and it should work now.

i removed the debug and gameobject as the debug does not work and can be done with different actions when needed

Also i added an event if no gyro available.

and an every frame bool (default true)

Can you test and confirm if it works?

Also if you have other ideas to add to the action let me know.
Title: Re: tilt functions on android devices
Post by: shamo on March 04, 2018, 08:07:31 PM
Hey, thanks for looking into this for me, much appreciated. :)
 I gave it a go, but cannot get it to function. I'm using a get vector3 XYZ to store the angles then output to float to string then Text set text. In the editor on play it displays an integer (as it should) On the phone it's just text... so something not communicating there.
Title: Re: tilt functions on android devices
Post by: djaydino on March 05, 2018, 05:27:38 AM
Hi,
Sorry i think i forgot to remove a part.

I did some more testing and every frame is useless in this case as the result will always be 0,0,0 so i removed that part.
here is the new version and tested on my android device
Title: Re: tilt functions on android devices
Post by: shamo on March 06, 2018, 06:49:44 PM
Thanks DJ, you are a legend! :D

All working ok, just refining how to implement it with the animations/ state machine setup I have.
 Any suggestions how to change the reading from the Attitude Euler angles from 1-360 to 1-180 and -1 to -180?
Thanks
Title: get device gyroscope action does work on android here
Post by: pierre nay on July 31, 2019, 03:15:57 AM
'Get device Gyroscope' action  on the ecosystem isnt updated so it does not work  with ANDROID but the one linked to this page does, thank you.