# Camera Rotation Probleme with iPhone

 0 hello, I had a little trouble about the manipulation in touch iphone. I want to move the camera left, right, top and bottom limited by touching any area of the ecranet I can not do: (help please: ( I wanted to be rotated in Prince of Persia Warrior Within in this video at 1:48 (Prince Of persia video's Link) sorry for my English .. With my code, the camera rotation is very bad. This is the code: ``````var xOffset : float; var yOffset : float; var target : Transform; var distance = 10.0; var height = 5.0; var speed = 5.0; var yMinLimit = -20; var yMaxLimit = 50; var xSpeed = 250.0; var ySpeed = 125.0; private var lastY =0.0; private var lastX = 0.0; private var gui : GUITexture; private var x = 0.0; private var y = 0.0; function Start () { var angles = transform.eulerAngles; x = angles.y; y = angles.x; } function Update(){ var position = transform.rotation * Vector3(0.0, height, -distance) + target.position; transform.position = position; for (var i=0; i< iPhoneInput.touchCount; i++){ var touch0 : iPhoneTouch=iPhoneInput.touches[0]; if(touch0.phase == iPhoneTouchPhase.Moved ){ x = touch0.deltaPosition.x / xOffset * xSpeed * 0.02; y = touch0.deltaPosition.y / yOffset * ySpeed * 0.02; } } } function LateUpdate(){ var rotation = Quaternion.Euler(y, x, 0); y = ClampAngle(y, yMinLimit, yMaxLimit); transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * speed); } 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); } `````` more ▼ asked Mar 24 '11 at 02:56 PM Chakroun Yesser 16 ● 4 ● 4 ● 6 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

Be the first one to answer this question

By Email:

Topics:

x3729
x1999
x841
x96

asked: Mar 24 '11 at 02:56 PM

Seen: 894 times

Last Updated: Mar 24 '11 at 03:02 PM