Ok I made this script for iphone swipe to look controls, but right now it jumps between the different rotations, how would I go about making it rotate smoothly?
var aPosX;
var bPosX;
var moveMag;
var moveSpeed : float = 2;
var moveInit : float = 10;
function Update () {
for (var i=0; i < iPhoneInput.touchCount; i++){
var touch : iPhoneTouch = iPhoneInput.touches[i];
if(touch.phase == iPhoneTouchPhase.Began){
aPosX = touch.position.x;
}
if(touch.phase == iPhoneTouchPhase.Moved){
bPosX = touch.position.x;
moveMag = (bPosX - aPosX)/moveSpeed;
moveMag = 0 - moveMag;
transform.Rotate(0, moveMag, 0);
}
if(touch.phase == iPhoneTouchPhase.Ended){
moveMag = 0;
}
}
Debug.Log(moveMag);
}
OK, I tinkered with your script… alot actually. since I dont have an iphone, or unity pro… I translated it to just using a mouse. and here is what I got:
First, I changed the move magnitude to always be equal to the difference in the last x position, vs the current x position. Doing this gives me an increment, rather than an addition from the original touch location and the current. (I think this would solve your problem as it is)
Next I added a little logic to continue the movement a little when you let up, or stop moving your finger/mouse.
Lastly, I removed the dependency of the moveMag in your touch, at let it roam freely. This means it wouldn’t stop immediately.
I am sure that you can translate the changes a bit. I have zip experience with the touch controls, so I commented them all out.
Heh, and a little more tweaking and I got it to auto rotate, let you change the rotation and then return back to the auto rotation after a little while.