- Home /
Android tilt control makes the object invisible on my device. Why ?
Hi! I am making a android game using the unity engine, and I was adding tilt control to the object that i want to control. I just wanted to make it move from left to right on landscape mode, I used this script:
function Update ()
{
var dir : Vector3 = Vector3.zero;
dir.z = Input.acceleration.y;
dir *= Time.deltaTime;
transform.Translate (-dir * 13);
}
And when I test it on android the object that I needed to control with tilt did not show up and everything else did. Can some one help me ?
Is it possible that the object just moved out of your camera's view?
Answer by FunkyL1zard · Jul 13, 2013 at 01:42 PM
I figured it out, Because the game was landscape I needed to monitor acceleration on X not on Y. Thanks for the help jaakaappi. Now it works.
var speed : float;
function Update ()
{
var dir : Vector3 = Vector3.zero;
dir.z = -Input.acceleration.x;
dir *= Time.deltaTime;
transform.Translate (-dir * speed);
}
I also made the speed a variable and inverted the axis because it was turning left in stead of right.
Your answer
Follow this Question
Related Questions
How to make camera position relative to a specific target. 1 Answer
Objects not becoming active with script 1 Answer
roll a ball pickups disappear on full screen 0 Answers
GameObjects are Pink 1 Answer
Specular Glitch on iOS Build 0 Answers