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…

You shouldn’t manipulate x, y, z, w components of quaternions. Use the functions like Euler.