- Home /
Gyroscope problem (nexus S, Android: 4.0)
Hello, all. I have a question, i have this script: var xForce : float = 10; var yForce : float = 10; var zForce : float = 10; var rotationRate: Vector3;
function Update () {
if (Gyroscope.rotationRate(1,0,0)) rigidbody.AddForce(Vector3(0, 0, 10));
if (Gyroscope.rotationRate(0,1,0)) rigidbody.AddForce(Vector3(10, 0, 0));
if (Gyroscope.rotationRate(-1,0,0)) rigidbody.AddForce(-Vector3(0, 0, 10));
if (Gyroscope.rotationRate(0,-1,0)) rigidbody.AddForce(-Vector3(10, 0, 0)); }
but unity gives this error:
Assets/scripts/marble controle (gyroscope).js(7,27): BCE0020: An instance of type 'UnityEngine.Gyroscope' is required to access non static member 'rotationRate'.
What does this mean? (I'm new to scripting in unity) I really don't know what i have to do. Ty, already.
@gilian Add "static" in the declaration
static var rotationRate:Vector3;
Does Gyroscope work on your android? Ive always needed to use acceleration for gyro-like events on my android.
I think it should work on my Nexus S. The nexus S is a phone that should have gyroscope.
i have this script:
var xForce : float = 10; var yForce : float = 10; var zForce : float = 10; static var rotationRate:Vector3;
function Update () {
if (Gyroscope.rotationRate(1,0,0)) rigidbody.AddForce(Vector3(0, 0, 10));
if (Gyroscope.rotationRate(0,1,0)) rigidbody.AddForce(Vector3(10, 0, 0));
if (Gyroscope.rotationRate(-1,0,0)) rigidbody.AddForce(-Vector3(0, 0, 10));
if (Gyroscope.rotationRate(0,-1,0)) rigidbody.AddForce(-Vector3(10, 0, 0)); }
and it gives this error:
Assets/scripts/marble controle (gyroscope).js(15,15): BCE0020: An instance of type 'UnityEngine.Gyroscope' is required to access non static member 'rotationRate'.
what am i doing wrong? Ty, already.
Answer by Vatio · Jun 29, 2012 at 12:29 PM
Little late, but the answer is you should use Input.gyro instead of Gyroscope
Then I simply get a Assets/Scripts/$$anonymous$$ovingAssetsv2.js(10,16): BCE0077: It is not possible to invoke an expression of type 'UnityEngine.Vector3'. Error. And from what I have learned, this message means something was forgotten. an = or a ;, something. Quesiton is, what?
Your answer
Follow this Question
Related Questions
function Touch 5 Answers
Access components in ALL children 1 Answer
Why is my script still running in other scenes? 1 Answer
Disable GameObject Only Father Not Children 2 Answers
gyroscope script problem. 1 Answer