- Home /
touch(pinch) to scale a game object
hello guys i have been going crazy with this: i have a game object in my scene and i want to rotate it on -+ x axis and scale it up and down (using pinch) with limits by touch. i think i got the rotate part covered, but for scale issue, i have no luck. i tried and tried local scale to achieve i want but no luck. so i would appreciate any help i can get. by the way this is for an augmented reality iOS app.
here is the code i am using for rotation, and like i said i would like to implement the scaling into this. i sincerely appreciate every help. thank you guys in advance
public var speedFactor : float = .002;
public var someThing : Transform;
function LateUpdate ()
{
processTouchInput();
}
function processTouchInput ()
{
if ( ! someThing ) {
Debug.LogError("Thing is null");
return;
}
if ( Input.touchCount != 1 ) {
return;
}
var firstFinger : Touch = Input.GetTouch(0);
if ( firstFinger.phase != TouchPhase.Moved ) {
return;
}
var theRotation : Vector3 = someThing.transform.rotation.eulerAngles;
var movement : Vector2 = firstFinger.deltaPosition;
var deltaY : float = movement.y * speedFactor * Time.deltaTime;
theRotation.y += deltaY;
someThing.transform.rotation = Quaternion.Euler(theRotation);
}
Comment