- Home /
Question by
Adrian_pro · Jun 15, 2015 at 10:55 PM ·
sizevuforiaresizeincrease
Set Resize limits
Hi all,
I ahave a qestion. I created a zoomin/zoom out script useing touch inputs for Vuforia AR. But I hat to have some limitiation in increasing and decreasing my object How can I do that? It whould be nice if you give an solutuin with a MAX float and MIN as float;
Thanks
This is my script:
using UnityEngine;
using System.Collections;
public class pinch : MonoBehaviour {
public float perspectiveZoomSpeed = 0.05f; // The rate of change of the field of view in perspective mode.
public GameObject _cube;
public float MaxZoom;
private Vector3 _mScale;
private Vector3 _mStartScale;
void Start(){
_mStartScale = _cube.transform.localScale;
}
void Update()
{
// If there are two touches on the device...
if (Input.touchCount == 2)
{
// Store both touches.
Touch touchZero = Input.GetTouch(0);
Touch touchOne = Input.GetTouch(1);
// Find the position in the previous frame of each touch.
Vector2 touchZeroPrevPos = touchZero.position - touchZero.deltaPosition;
Vector2 touchOnePrevPos = touchOne.position - touchOne.deltaPosition;
// Find the magnitude of the vector (the distance) between the touches in each frame.
float prevTouchDeltaMag = (touchZeroPrevPos - touchOnePrevPos).magnitude;
float touchDeltaMag = (touchZero.position - touchOne.position).magnitude;
// Find the difference in the distances between each frame.
float deltaMagnitudeDiff = prevTouchDeltaMag - touchDeltaMag;
_cube.transform.localScale = Vector3.Lerp(_mStartScale, _mStartScale * deltaMagnitudeDiff , perspectiveZoomSpeed);
}
}
}
Comment
Your answer
Follow this Question
Related Questions
How do I make a controllable horde increase in population? 0 Answers
Cloud recognition in Vuforia 0 Answers
how to change the size of a box collider in c# 2 Answers
Change size of an UI object ( Javascript ( Unityscript) ) 0 Answers
Minimizing App Size 1 Answer