One thing to keep in mind about rotation is that Euler values should only ever be written to, never read from. This means that you can't just clamp the Euler values of the rotation and call it a day. What you should do instead is track the amount in both axes that the object is to be rotated outside of the rotation itself, and clamp those values. So, you'd have two floats xRotation and zRotation, make the user input change those values frame to frame, clamp them, and assign them to the rotation via Quaternion.Euler.
If you post it, we can look at what you need and what the problem is. Asking "Can you look at my code" is a bit of a weird way of asking for help. Post the code in question and the problem you are having, be as clear as possible and we can probably figure out what needs to be changed.
private Touch touch; private Vector2 touchposition; private Quaternion rotationx, rotationz; private float tiltspeedmodifier = 0.1f; void Update(){ if(Input.touchCount>0) { touch = Input.GetTouch(0); switch(touch.phase){ case TouchPhase.Moved: rotationx=Quaternion.Euler( -touch.deltaPosition.x * tiltspeedmodifier,0f,0f); transform.rotation= rotationx * transform.rotation; rotationz= Quaternion.Euler( 0f,0f, -touch.deltaPosition.y * tiltspeedmodifier); transform.rotation= transform.rotation * rotationz; break; } } } }
When you post code, use [code ]code tags[/code]. Make rotationx and rotationz floats instead of Quaternions, and add the appropriate deltaPosition value to them each frame. It'll look a little bit like: Code (csharp): float rotationx = 0f; void Update() { ... rotationz += Input.deltaPosition.x; transform.rotation = Quaternion.Euler(rotationx, 0f, rotationz);