Using Touch Functionality in UTiny

Overview

Table Realms uses emulated touch functionality in Unity Tiny, which allows players to provide inputs into the game world using touchable devices.

Initialisation of Touch Input

Before the touch functionality can be used, it needs to be initialised within the UTiny project. This is done by using the Table Realms Tiny API to call the following function:

TableRealmsTiny.Input.InitializeTouch(GetMyID(), GameSystem.world);

This function is used in your game’s script file to set up and register the actions and events that are required for the Table Realms touch passthrough components to work.

Post Initialisation

Once the touch input component has been initialised in UTiny, it can be used to perform a number of different functions.

Getting Position

  • GetPosition () - Used to return the coordinates of the latest touch position.
  • GetPosition().x - Used to return the horizontal coordinates of the latest touch position.
  • GetPosition().y - Used to return the vertical coordinates of the latest touch position.

Detecting Input

  • IsInputDown () - Returns either true or false, depending on whether the touch component is being touched.

Detecting a Drag Input

GetDrag (world:ut.World, touchName:string):{id,x,y,speed,delta}
  • Used to return an object with the ID, coordinates, speed, and delta. The “touchName” parameter needs to be populated with the name of the Touch Passthrough component within the Aug file.
GetDragDelta (world:ut.World, touchName:string):Vector2
  • Used to return the delta of the drag that occurred.
GetDragSpeed (world:ut.World, touchName:string):Vector2
  • Used to return the speed of the drag that occurred. This speed can be translated into a force, such as flicking a ball.