FPS Controls for mobile devicesFPS Controls for mobile devices
This asset will provide you with FPS controls for mobile devices that is very easy to setup and use.FPS Controls for mobile devices
This asset will provide you with FPS controls for mobile devices that is very easy to setup and use.Overview
You can test it here (WebGL): https://e-ugovor.rs/FPS_Controls/
Or you can download apk file and test it on your android device: https://www.dropbox.com/s/nuj1bwive9n324b/FPS%20Controls.apk?dl=1
This asset will provide you with FPS controls for mobile devices that is very easy to setup and use.
Features
- Lightweight
- Easy to setup
Requirements
Requires Unity3D 2018.4 or newer
Instructions
• Drag and drop “Joystick.prefab“ from “Prefab” folder into your scene.
• Add EventSystem to your project hierarchy (Right click inside project hierarchy – UI – EventSystem)
• Use “JoystickLeft.positionX” static variable inside your scripts to get left joysticks X axis value, use “JoystickLeft.positionY” to get Y axis value (you will get value from -1 to 1 for x and also from -1 to 1 for y axis).
*Example
Vector3 moveX = JoystickLeft.positionX * speed * transform.right;
Vector3 moveY = JoystickLeft.positionY * speed * transform.forward;
rigidbody.MovePosition(transform.position + moveX * Time.fixedDeltaTime + moveY * Time.fixedDeltaTime);
In case that your character doesn’t have rigidbody you can use this:
transform.position = transform.position + moveX * Time.fixedDeltaTime + moveY * Time.fixedDeltaTime;
- For rotation use JoystickRight.rotX and JoystickRight.rotY.
* Example
void Update() {
transform.rotation = Quaternion.Euler(JoystickRight.rotY, JoystickRight.rotX, 0);
}
• To detect if shot button is pressed you can use JoystickRight.shot static variable. It will return true when shot button is pressed and false when it is released.
• To detect if jump button is pressed use JoystickRight.jump. It will return true whan jump button is pressed and false when it is released.
Other items by this author
Category | App Templates / Unity / Assets |
First release | 28 August 2020 |
Last update | 28 August 2020 |
Operating Systems | iOS 10.0, Android 7.0, Android 8.0, iOS 11.0, Android 9.0, iOS 12.0, MacOS 10.14, Windows 7, Windows 8, Windows 10, Unity 2019, iOS 8.0, iOS 9.0, Android 5.0, Android 6.0 |
Tags | android, iOS, jump, shoot, shooter, character, person, first, virtual, rotation, movement, fps, controls |