- Home /
Accelerometer works on phone until build exe
Hello- I've got an Android phone which I am using the accelerometer to navigate around the game. The issue is that the accelerometer works perfectly until I build the game. Then the game doesn't pick up the accelerometer at all. I don't know where to start troubleshooting this.
edit: I am using Unity Remote on Android to access the accelerometer data. I am using a Windows box to run the game. The Android phone talks to the game via USB or wireless ADB. So the accelerometer data gets into the game easily in edit mode, but in build mode it no longer works. This is something that I wish Unity 3D would document on their website- does it work or not? If it isn't supported, why doesn't it talk? How can I make it talk? Anyone have any ideas? ~Sophi
Yes. It is a windows box. So when I do a build, it gives *.exe and a data folder.
($$anonymous$$aybe @Sophi is using the Android remote, so can control the game running in the editor. A standalone build doesn't talk to the Android remote.)
See edits to my question above. @Graham are you saying that Unity remote isn't supported in a standalone build? That seems misleading from Unity- that it works in edit but not in build?
Answer by Bunny83 · Nov 12, 2014 at 02:09 PM
As mentioned in some comments, the Unity Remote application is only for testing in the editor and not a general purpose remote control which could be used in standalone builds.
However the answer from Unity (at least the part the OP quoted, maybe it's taken out of context):
It is not possible to use the android device as a controller for a standalone application outside of the editor
... is actually not true. You can't use the Unity Remote app since it's made for the editor. However you can create your own remote application with Unity that uses the Network interface to transmit any data you want to another application. Of course you have to develop that app, which data is transmitted and the data handling yourself.
So it is possible "to use your android device as controller for a standalone build", but not with the Unity Remote app.
ps: the source code for the Unity Remote is available for free on the Asset Store. However you need Unity pro to build it yourself since it uses Sockets. Keep in mind that you have to code the "receiving part" in your standalone application yourself.
Thank you so much! I have Pro and have another standalone thing in my game that communicates over serial (bit banging), so I already have the "receiving part"!
Answer by ashique · Nov 12, 2014 at 01:23 PM
Is Device supporting accelerometer???
Yes. The device supports the accelerometer. It works perfectly in edit, just not in standalone.
Answer by Sophi · Nov 12, 2014 at 01:08 PM
Got the official word from Unity 3D support: "It is not possible to use the android device as a controller for a standalone application outside of the editor."
I have to say that it is unfortunate that they allow you to access the accelerometer, gyro and camera in edit but not in build!
How is the documentation misleading about the Unity Remote?
Unity Remote 4 is an application that allows you to use your target device as a remote control for your project in Unity editor.
First of all is says to use your "target device", so that means that you build for either Android or iOS. It also says to use the device as remote control inside the "editor". That it's for use in the editor is mentioned all over that page. For example:
When you use Unity Remote, the game actually runs in the Unity editor [...]
For short: Unity Remote is a development tool that simplifies testing of your project when targetting Android or iOS.
ps: The description of the Remote app itself is also quite clear.
Yes you are right. I just read what I wanted to, but also it is counter-intuitive at least to me, that something wouldn't work in the build. I sincerely hope that there aren't other surprsies such as "transform" working differently in build than in editor! Also there are quite a few tutorials on youtube and such referencing the "use your phone as a controller!" Even universities give courses saying this. So...it is not clear to any of us...or we all just read what we want to. In any case, I now have a direction to go in for my custom controller and it is not Unity Remote!
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
accelerometer speed 1 Answer
3D: how to avoid jerks in a character movement using accelerometer 1 Answer
Unity for free commercial use ? 0 Answers