I’ve seen a few other posts closely related to the topic, but can’t seem to find a clear solution.
Objective:
Attach this .js to a GO (Cube) that will rotate when the user swipes the screen. Instead of ending the rotation when the user ends the swipe, the cube should continue to smoothly come to a stop in the same direction it is rotating.
Here is the method for rotating the cube now:
var rotationSpeed : float = 10.0;
function Update() {
if (iPhoneInput.touchCount == 1 iPhoneInput.GetTouch(0).phase == iPhoneTouchPhase.Moved) {
//get Movement of finger since last update
var touchDeltaPosition : Vector2 = iPhoneInput. GetTouch(0).deltaPosition;
transform.Rotate(mainCam.transform.up * -touchDeltaPosition.x * Time.deltaTime * rotationSpeed, Space.World);
transform.Rotate(mainCam.transform.right * touchDeltaPosition.y * Time.deltaTime * rotationSpeed, Space.World);
}
}
This rotates the cube in my scene just fine, however I would somehow like to lerp (or slerp?) the end of the rotation to give it a more “smooth” presentation.
Any suggestions?
Thanks in advance…