rotating object or camera with finger on android

Hi,

I’m a beginner on unity and scripting and i’m working on architectural design. I have a 3D model of a house i have to visualize on android devices.
I first made the project for web visualisation, using a camera with the “MouseOrbit” script from unity.
Everything worked fine with this script in firefox, so i decided to make the android version, without changing anything.

The result is a nice feeling rotating around the house with the finger, the camera move seems to be great, at least as long as your finger doesn’t quit the screen. The problem is that the camera reset itself at a totally different angle each time you retouch the screen ( which you have to, in order to complete a full rotation for example ).

I looked around, tried some scripts that seemed to be written for android on the asset store like the HeadLook tutorial, but i always gets this problem, or i get a camera move totally wrong making it impossible to target what you want when visualising,

So my questions are:

  • is there something i could add to the “MouseOrbit” script that would fix the camera wrong location when i re-touch the screen or would optimize it for touch screen?
    ( here is the script :
var target : Transform;
var distance = 10.0;

var xSpeed = 250.0;
var ySpeed = 120.0;

var yMinLimit = -20;
var yMaxLimit = 80;

private var x = 0.0;
private var y = 0.0;

@script AddComponentMenu("Camera-Control/Mouse Orbit")

function Start () {
    var angles = transform.eulerAngles;
    x = angles.y;
    y = angles.x;

	// Make the rigid body not change rotation
   	if (rigidbody)
		rigidbody.freezeRotation = true;
}

function LateUpdate () {
    if (target) {
        x += Input.GetAxis("Mouse X") * xSpeed * 0.02;
        y -= Input.GetAxis("Mouse Y") * ySpeed * 0.02;
 		
 		y = ClampAngle(y, yMinLimit, yMaxLimit);
 		       
        var rotation = Quaternion.Euler(y, x, 0);
        var position = rotation * Vector3(0.0, 0.0, -distance) + target.position;
        
        transform.rotation = rotation;
        transform.position = position;
    }
}

static function ClampAngle (angle : float, min : float, max : float) {
	if (angle < -360)
		angle += 360;
	if (angle > 360)
		angle -= 360;
	return Mathf.Clamp (angle, min, max);
}

)

-or, should i use a script written for android? I tried to find one equivalent to the “MouseOrbit”, but results are so messed up :frowning: Nothing to see with what i get with this basic “MouseOrbit” Script from Unity

-or should i try to make the house rotate instead of the camera? If yes, how can i do that?

Bonus question:

  • is there a way to add a pinch zoom with that kind of application?

Thanks for your help

i am interested in this two, let me know if you found a solution!

hello, i am trying to do the same thing , so please inform me, did you find out the solution?

did any one find any solution ??