Orientation sensor

Hello,
I tried to add a reaction to the orientation sensor to the game. As in the example in the screenshot, but there was no reaction on the android smartphone. Is there any mistake here? Or do I need something else to make the phone respond to the orientation sensor?

If it’s any help, the orientation sensors don’t work for me either, and I haven’t been bothered to investigate. Instead I’m using the motion sensors. They seem to work just fine.

Need to change the orientation sensor to the motion sensor, and the Action remains unchanged as in the screenshot?

No, you’ll need to change the actions too. See the GDevelop Wiki on sensors for more info.

To give force to the object instead of the orientation sensor, I need to replace it as in the screenshot?

Yes, though I think you need to swap the 2 functions. Look at the Device Orientation Ballgame that’s given in the GDevelop examples and see how it’s done in there.

I did as in the screenshot below. The ball began to move. But when you turn the smartphone to a horizontal orientation, the ball does not feed down, but rises up. How to fix it?

Try making the y value negative.

Like this? DeviceSensors::AccelerationY() * -10

Or is it possible to simply change the direction of gravity relative to the position (rotation) of the smartphone?

Try it and see - trial and error is a great way to experiment and learn.

Yes, this is the best way. Thanks for your tips! Everything worked out.

1 Like