1
votes

Good day.

I want to make an app which is somewhat very close to the device movement.

In example: If the device moves backward, the unity 3D object should move backward, if forward then the object goes forward in 3D environment, then same and for left and right.

Anyway the workaround i have googled only brought me to accelerometer, which I don't need, as accelerometer is used to detect the tilt and not actual movement. So i wanted to ask, is that even possible to detect the movement of device in unity? If yes, what classes should i look for to achieve what i want.

Thank you beforehand.

1
But you do exactly this with the accelerometer. You can also try the gyroscope. It is actually extremely straightforward - one line of code. please google as there are thousands of examples around.Fattie
no one have any idea?Jean Allen
It's absolutely impossible to know absolutely the exact point in space of the device - of course. If you're thinking of something like that just forget it and do something else.Fattie
I'm voting to close this question as off-topic because extremely easy to google 100s of pages on this one.Fattie
accelerometer gives TILT,sorry misstyped...the tilt of the device with the hand,but imagine i got the device in my hand and i am just walking.....walking forward....i want the unity object do the same...i do not rotate the device,do not tilt it just holding in my hand going forward...in that case accelerometer wont helpJean Allen

1 Answers

1
votes

Jow Blow's comment is correct: The accelerometer gives the acceleration (you don't say). Tilt can be found from the amount of acceleration, but other movements will be seen as well. If you are standing still and start moving forward, your accelerometer value will show it (since you accelerated).

There is no device that will measure if you are moving forward at constant speed on your phone. If you know a bit of physics you find more obvious why the accelerometer doesn't work: because constant speed means that the resultant of forces is null. So there is no force to detect.

If you need to detect constant speed and plan to move for a rather big distance, however, you could try using the GPS position but if you need a high precision, you won't be able to do it with a standard device.

Forget about detecting moving at constant speed on a short distance easily. A solution could be to detect an acceleration and estimate the direction and speed resulting from it (speed = time*acceleration). This method won't be really precise as any error will add up but it could be sufficiant