- Home /
Android gyroscope
I am creating a game for Android where using the gyroscope device the camera moves to the right and to the left thanks to this script, as follows:
#pragma strict
public var goTransform:Transform;
private var vel:int = 1;//how fast the game object is being moved
function Awake()
{
//get this GameObject's Transform
goTransform = this.GetComponent(Transform);
}
function Update () {
transform.Translate(Input.acceleration.x, 0,0);
goTransform.position.z = goTransform.position.z + vel-1;
}
the camera moves but does not rotate, what should I add?
Comment
Well you only have a Translate function and something about position ... how could it be diffrent ? You need to use Rotate and/or transform.rotation if you want to modify the rotation :)
Btw, goTransform is useless here, this.GetComponent(Transform) is equivalent to 'transform' ... like you do for transform.Translate ^^
Your answer
