- Home /
Question by
Nieniepanini · Mar 22, 2012 at 08:21 PM ·
androidpivottilt
Limited tilt ojbect on pivotpoint
Hi all
I hope someone can help me out. I am struggling with a little game which i cannot get the tilt function working. The game is for android and i want to use the tilt sensor in the phone to tilt an object on it's pivot point.
This is what i have so far...
using UnityEngine;
using System.Collections;
public class TiltAround : MonoBehaviour
{
private Quaternion localRotation;
public float speed = 1.0f;
void Start ()
{
localRotation = transform.rotation;
}
void Update()
{
float curSpeed = Time.deltaTime * speed;
localRotation.y += Input.acceleration.x * curSpeed;
localRotation.x += Input.acceleration.y * curSpeed;
transform.rotation = localRotation;
}
}
But the object is moving anywhere but not staying at one point (the pivot) and tilting the ojbect itself. I hope someone can point me in the right direction..
Comment
Your answer
Follow this Question
Related Questions
Accelometer controls for iOS and android 2 Answers
Link Input.acceleration to camera 2 Answers
C# Move object by tilting on android device. 5 Answers
Face Direction of Tilting 1 Answer
physics.gravity with tilt game 1 Answer