- Home /
How to make Headbobber on joystick Android
Hi all. I'm looking to make a headbobber on joystick mobile.
I have found this script wiki.unity3d.com/index.php/Headbobber but i don't have any idea to give Input.GetAxis("Vertical") and Input.GetAxis("Horizontal") because i'm using a prefab of First Person Controls for Android mobile.
Can you give me any idea to solve this problem?
Simply swap Input.GetAxis("Vertical") and Input.GetAxis("Horizontal") for the Android controller input values.
Answer by AlucardJay · May 20, 2013 at 01:43 PM
I have never used it, but reading the scripts now, FirstPersonControl.js reads inputs from Joystick.js . Joystick.js has a variable called position which is a Vector2, and stores a +- normalized value based on what is happening with the GUI and the touch.
So, on the headbob script, you start with a variable like that on the FirstPersonControl script :
var moveTouchPad : Joystick;
Drag and drop your Joystick there the same way as for the FirstPersonControl.
Now in the Update, just swap out horizontal and vertical to use the values from Joystick position (Vector2) :
// horizontal = Input.GetAxis("Horizontal");
horizontal = moveTouchPad.position.x;
// vertical = Input.GetAxis("Vertical");
vertical = moveTouchPad.position.y;
Hi. i have test this and work perfectly.
thank you very much
Hi, thanks for share, i have a compilant error with the "waveslice" in Unity 3.4, do you know how to fix this perhaps?
Answer by JuanDavisT21 · May 22, 2014 at 03:26 AM
Hi, thanks, but have a compilat error with waveslice . Could you help me with that?
Your answer
Follow this Question
Related Questions
Unity 2D Mobile Game Drawing Mechanic 0 Answers
How to differentiate touches on mobile devices 1 Answer
Bug? Need to wait about 10 seconds to get back to normal 1 Answer
android touch input 1 Answer
Joypad help 0 Answers