playMaker

Author Topic: tilt functions on android devices  (Read 1374 times)

shamo

  • Playmaker Newbie
  • *
  • Posts: 38
    • View Profile
tilt functions on android devices
« on: February 27, 2018, 07: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

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4615
    • View Profile
    • jinxtergames
Re: tilt functions on android devices
« Reply #1 on: February 27, 2018, 11:49:45 PM »
Hi.
I believe you can use "Get Device Roll" action.

shamo

  • Playmaker Newbie
  • *
  • Posts: 38
    • View Profile
Re: tilt functions on android devices
« Reply #2 on: February 28, 2018, 12: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.

shamo

  • Playmaker Newbie
  • *
  • Posts: 38
    • View Profile
Re: tilt functions on android devices
« Reply #3 on: February 28, 2018, 03: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?

shamo

  • Playmaker Newbie
  • *
  • Posts: 38
    • View Profile
Re: tilt functions on android devices
« Reply #4 on: March 02, 2018, 03:15:49 PM »
Anyone been able to implement the 'Get Gyroscope' on Android?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4615
    • View Profile
    • jinxtergames
Re: tilt functions on android devices
« Reply #5 on: March 03, 2018, 10:46:59 AM »
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.

shamo

  • Playmaker Newbie
  • *
  • Posts: 38
    • View Profile
Re: tilt functions on android devices
« Reply #6 on: March 03, 2018, 04: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.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4615
    • View Profile
    • jinxtergames
Re: tilt functions on android devices
« Reply #7 on: March 04, 2018, 06: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.

shamo

  • Playmaker Newbie
  • *
  • Posts: 38
    • View Profile
Re: tilt functions on android devices
« Reply #8 on: March 04, 2018, 06: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.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4615
    • View Profile
    • jinxtergames
Re: tilt functions on android devices
« Reply #9 on: March 05, 2018, 03: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

shamo

  • Playmaker Newbie
  • *
  • Posts: 38
    • View Profile
Re: tilt functions on android devices
« Reply #10 on: March 06, 2018, 04: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
« Last Edit: March 07, 2018, 03:18:20 AM by shamo »

pierre

  • Playmaker Newbie
  • *
  • Posts: 2
    • View Profile
get device gyroscope action does work on android here
« Reply #11 on: July 31, 2019, 12: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.