1 of 11

Technology Investigation

Gyroscope and Touch Input

Yiwei Tu

2 of 11

Why?

  • Inspired by a popular mobile game – PUBG Mobile
    • Utilize built-in Gyroscope to improve aiming
  • Equipment is easy to access – iPhone, iPad, Android phone, etc.

3 of 11

Special Features

  • Gyroscope:
    • Orientation
    • Angular Velocity
  • Touch Input:
    • Position: 2D vector
    • Phases: Began, Moved, Ended
    • Count: how many touches on the screen

4 of 11

Adaptation to Support MP2

Translation Sliders + Toggle

Rotation Sliders + Toggle

Scaling Sliders + Toggle

5 of 11

Translation

  • Use one Finger, tap the object to select
  • Move the Finger and the selected object will move following the finger movement
  • How to move in all directions?
    • Touch position is 2D – x, y direction on screen
    • Can we use RayCast like we did in MP3?
    • My solution:
      • Camera Orbit
      • + Plane Equation.
      • + Line Equation.
  • v0 = initial position - Camera position
  • D = Dot(v0, camera.forward)
  • v = New Touch Point - Camera position
  • theta = angle between Camera.forward and v
  • d = D / cos(theta)
  • New position = camera.location + d * v

6 of 11

Scaling

  • Use two fingers
  • Scaling ratio controls the scaling vector for the selected object
  • Store the initial distance between two finger touch location as InitalDistance
  • CurrentDistance represent the current distance between two finger touch position

 

7 of 11

  • Built-in Gyroscope on mobile devices
  • Unity Input system

Rotation

Demo Video

8 of 11

9 of 11

Use of Traditional Tech

  • Use button UI elements
    • to create objects and
    • to rotate main camera around the world
  • Why keep buttons?
    • Simple and straightforward
    • Could use finger gestures – triple tap…
      • But need to remember every gesture functionality

10 of 11

  • Explore more on Unity Input system – mouse input, touch input, gyroscope input, etc.
  • Practice and manipulate camera rotation
  • Conflict between the old input system and the new input system package
  • Convert Touch position to World position

Take-Away

11 of 11

Thank You!