0
Answered

Adventure Camera Zoom in Mobile Mode

efekanpulatli 3 months ago in Game Creator updated by Walter Bedford 4 weeks ago 4

Hello,i cannot zoom in mobile mode with adventure camera 

How can i achieve that by two fingers classic zooming gestures?

Unity version:
2019
Game Creator version:
1.1.6

Answer

+1
Answer

This worked pretty well,

if (Input.touchCount == 2) { Touch touchZero = Input.GetTouch(0); Touch touchOne = Input.GetTouch(1);
Vector2 touchZeroPrevPos = touchZero.position - touchZero.deltaPosition; Vector2 touchOnePrevPos = touchOne.position - touchOne.deltaPosition;
float prevMagnitude = (touchZeroPrevPos - touchOnePrevPos).magnitude; float currentMagnitude = (touchZero.position - touchOne.position).magnitude;
float difference = (currentMagnitude - prevMagnitude) / 200.0f;

this.desiredZoom = Mathf.Clamp( this.desiredZoom - difference * this.zoomSensitivity, this.zoomLimits.x, this.zoomLimits.y );
print("desired zoom " + this.desiredZoom + " difference " + difference); }

+1
Answer

This worked pretty well,

if (Input.touchCount == 2) { Touch touchZero = Input.GetTouch(0); Touch touchOne = Input.GetTouch(1);
Vector2 touchZeroPrevPos = touchZero.position - touchZero.deltaPosition; Vector2 touchOnePrevPos = touchOne.position - touchOne.deltaPosition;
float prevMagnitude = (touchZeroPrevPos - touchOnePrevPos).magnitude; float currentMagnitude = (touchZero.position - touchOne.position).magnitude;
float difference = (currentMagnitude - prevMagnitude) / 200.0f;

this.desiredZoom = Mathf.Clamp( this.desiredZoom - difference * this.zoomSensitivity, this.zoomLimits.x, this.zoomLimits.y );
print("desired zoom " + this.desiredZoom + " difference " + difference); }

Answered

I'm afraid mobile controls do not support zooming in and out. But as you point out, creating a small snippet like you did should solve the issue.

+1

Could you please explain in steps how I can add this snippet? I would appreciate very much! thank you :)

+1

I am also looking for this feature on mobile. Can you elaborate on how to implement this code please?