The realization of multi-touch is achieved by using the method of the input class.
From Edit-project settings-input You can see the axes that input can get.
To read an axis you can use the Input.getaxis method to get the following default axes: "Horizontal" and "Vertical" are mapped to the joystick, A, W, S, D, and arrow keys (direction keys). "Mouse X" and "Mouse Y" are mapped to the mouse, "Fire1", "Fire2" "Fire3" buttons that map to the keyboard's CTRL, ALT, CMD, and middle mouse keys or controllers
iOS and Android devices can support multi-touch. You can access the state data in the last frame by touching each finger on the screen through the Input.touches property collection.
As the devices move, their accelerometer hardware reports their linear acceleration change data in three-dimensional space along three spindles. You can use this data to detect the current direction of the device (relative to the ground) and the sudden change in direction.
The hardware will immediately return to the gravity value as it accelerates along an inductive axis. A value of 1.0 represents the gravitational acceleration of +1g along the direction of a given axis, and a value of 1.0 represents the gravitational acceleration of -1g. If you keep the device vertical (the home key is below) in front of you, then the x-axis is the direction to your right, the y-axis is straight, and the z-axis is the direction you are facing.
You can read the Input.acceleration property to get acceleration information for the device. You can also use the Input.deviceorientation property to get the azimuth offset of the device in three-dimensional space. Detecting azimuth changes is useful when you want to make game behavior, which is different when the user rotates the device or takes the device.
The speed sensor is able to poll multiple times in each frame, and to access all the speed samples from the previous frame you can read the Input.accelerationevents property collection. This can be very useful in reorganizing player actions.
1 usingUnityengine;usingSystem.Collections;2 Public classExampleclass:monobehaviour {3 PublicGameobject particle; 4 voidUpdate () {5 for(vari =0; i < Input.touchcount; ++i) {6 if(Input.gettouch (i). Phase = = Touchphase.began) {//Construct a ray from the current touch coordinates7Ray Ray =Camera.main.ScreenPointToRay (Input.gettouch (i). position);8 //Create a particle if hit9 if(Physics.raycast (Ray))TenInstantiate (particle, transform.position, transform.rotation) asGameobject; One } A } - } -}
Unity3d for multi-point touch