A
A
Alexey Fobius2021-08-09 00:04:26
C++ / C#
Alexey Fobius, 2021-08-09 00:04:26

How to track the position of the phone in space?

Greetings, the problem is that I need to receive data from the phone, and, depending on its position, move the cube in the game.

For example: I raise the smartphone up, the cube also rises, etc.

As I understand it, this can be solved using an accelerometer, but I don’t fully understand how.

Of course, I tried to register the movement based on the axes of the accelerometer, but it apparently only reads the rotation, but not the position, as it seems to me

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Developer, 2021-08-09
@samodum


For example: I raise the smartphone up, the cube also rises, etc.

Yes, it is solved by the accelerometer. See the acceleration along the Z coordinate. Depending on this value, you set the speed of the cube.
The phone does not determine the position in space, and you do not need it.
You take the cube in the current coordinates, and while you are holding the phone up, the acceleration along the z coordinate changes. You apply this to the current coordinates of the cube and change its position in space. When you stop picking up the phone, the acceleration will become 0 and the cube will stop at a certain height, which you calculated in the process of changing the acceleration
of course I tried to register the movement based on the axes of the accelerometer, but it apparently reads only the rotation, but not the position, as it seems to me

No. The accelerometer does not track rotation, but acceleration along three axes

N
Nekit Medvedev, 2021-08-09
@NIKROTOS

And how is the accelerometer supposed to determine the height? First, find out what it is, I can offer work with a camera for these cases, for example:
https://www.air-gun.ru/social/readtopic/prostoy_da...
It won't work in its pure form, but I think you can think of it.
Another option, you can try to read the rise according to the accelerometer readings, it is unlikely that people will lift the phone perfectly up.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question