|
| 1 | +# How To Make a Simple Joystick |
| 2 | +## The One In Stand Assests from Unity3D |
| 3 | + |
| 4 | +This prefab is with the move button and jump button. And there is other 4 prefabs in the package too. |
| 5 | + |
| 6 | + |
| 7 | +### How To Get It? |
| 8 | + Assets > Import Package > CrossPlatformInput |
| 9 | + |
| 10 | +### How To Use It? |
| 11 | +1. Add the prefab to the scene; |
| 12 | +2. Get the axis like the original Input Manager. |
| 13 | + |
| 14 | +**i.e.** |
| 15 | + |
| 16 | + using UnityStandardAssets.CrossPlatformInput; |
| 17 | + ... |
| 18 | + //just like using Input Manager |
| 19 | + x = CrossPlatformInputManager.GetAxis("Horizontal"); |
| 20 | + y = CrossPlatformInputManager.GetAxis("Vertical"); |
| 21 | + ... |
| 22 | + CrossPlatformInputManager.GetButtonDown("Jump"); |
| 23 | + |
| 24 | + |
| 25 | +**P.S.** |
| 26 | +- The cross platform input is from the unity3d standard asses, make sure that you have already install it. |
| 27 | +- More About It, Please Read CrossPlatformInputGuidelines in the package folder. |
| 28 | + |
| 29 | +## [Simple Joystick (Move Rotate Fire)](https://www.assetstore.unity3d.com/#!/content/59691) |
| 30 | +This is a different joystick, which support movement rotation and fire/jump input. |
| 31 | + |
| 32 | + |
| 33 | +And it will release on assest store days later. |
| 34 | + |
| 35 | +### How To |
| 36 | +1. Download And Import The Package |
| 37 | +2. Drag and drop the `ControlCanvas` to the scene |
| 38 | +3. Add `EventSystem` to the scene too |
| 39 | +4. It is done (There is a sample scene in the package, you can double click to open it.) |
| 40 | + |
| 41 | +#### Download And Import The Package |
| 42 | +[Simple Joystick on Assest Store]((https://www.assetstore.unity3d.com/#!/content/59691), the assest package will be released days later. |
| 43 | + |
| 44 | +#### Drag and drop |
| 45 | + |
| 46 | + |
| 47 | +#### Add EventSystem |
| 48 | + |
| 49 | +And it is ok to keep the default parameters. |
| 50 | + |
| 51 | +#### Use the 3 static classes to get Axis and Fire |
| 52 | +- JoystickMove.instance. (H and V) |
| 53 | +- JoystickRotate.instance. (H and V) |
| 54 | +- JoystickFire.instance.Fire |
| 55 | + |
| 56 | +##### Example |
| 57 | + void Update () { |
| 58 | + transform.Translate(new Vector3(JoystickMove.instance.H,0f,JoystickMove.instance.V)*speed*Time.deltaTime); |
| 59 | + |
| 60 | + |
| 61 | + transform.LookAt(transform.position+new Vector3(JoystickRotate.instance.H,0f,JoystickRotate.instance.V)); |
| 62 | + |
| 63 | + if(JoystickFire.instance.Fire){ |
| 64 | + Debug.Log("fire"); |
| 65 | + } |
| 66 | + }// this is in the sample scene `CubeControl` |
0 commit comments