- Home /
Rotating object with iPhoneTouch
Hi,
I am trying to rotate an object based off the finger movement on the iPhone screen. So far, I have the following code.
function Update ()
{
if (iPhoneInput.touchCount > 0 && iPhoneInput.GetTouch(0).phase == iPhoneTouchPhase.Moved) {
// Get movement of the finger since last frame
var touchDeltaPosition:Vector2 = iPhoneInput.GetTouch(0).deltaPosition;
transform.eulerAngles = Vector3(0, touchDeltaPosition.x, 0);
}
}
This does rotate the object, but it does very quickly. This is based off the tuochDeltaPosition.x set for the Y. However, I'm not sure how else to fix this.
I'd like to be able to move a finger to the left of the screen and have the object rotate in -Y and a finger move to the right would rotate +Y. Also, I'd like for an up and down finger move to the object around the x.
I'd greatly appreciate any help! I can't seem to find any samples for the iPhone which would help to figure this out.
Thanks,
Wes
Answer by The 3D Ninja · May 27, 2010 at 04:53 PM
I found a solution to this issue and it can be found in the Unity iPhone Development forums.
http://forum.unity3d.com/viewtopic.php?t=52783
-Wes