How to get the iOS device orientation?

Hi…,

I try to get the iOS device orientation with these two values in Godot 4.5 (beta):

Input.get_magnetometer()
Input.get_gravity()

I fail, I don’t understand the magnetometer Vector3.

Any tips or tutorials?

Thanks

Mike

In DisplayServer there is a method called screen_get_orientation()

The docs are amazing, I always go there first when I have a question. Even when I have a problem I don’t know how to approach, the method lists often have functions in them that give me clues. It never ceases to amaze me how complete they always seem. I have yet to encounter a problem that has not already been realised, investigated and solved somewhere already and incorporated into a classes methods somewhere.

Dear @pauldrewett,

thank you for the link.

Sorry, my question was not precise enough. I don’t need the portrait or landscape orientation.

I need the real orientation in 3D space in form of

var _basis := Transform3D().basis

e.g. for a compass app.

Any help appriciated

Mike

1 Like

Oh sorry! I misunderstood. I must admit I thought ‘why is he looking at gravity and magnometer?’, but now that makes sense.

I have no experience of using them, sorry.

There is this old thing in the asset library:

Might be of some help. I also did a search for you and found this:

Again might be of some use. Sorry I could be of no real help.

(Just looked those up for you because I felt bad about the misunderstanding, sorry again).

1 Like

Hi again @pauldrewett,

wow, I’ve got the Mobile Sensors Demo to run in Godot 4.5 (beta), and it works as I wanted to. :partying_face:

I’ve tried it first with ChatGPT, but failed miserably. Next time, I will first check the Godot Asset Library.

Thank you very much again

Mike

1 Like