- Home /
How to make Dual Joysticks for Android and IOS?
I am really sorry if I'm asking a question that has already been answered, but I can't figure out how to make dual joysticks that will work on Android and iOS. I'm fine with having two different scripts, one for Android and one for iOS, but right now I can't figure out how to make it work with my own script. Here is the script I use to move around:
using UnityEngine;
using System.Collections;
public class PlayerMove : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKey(KeyCode.LeftArrow))
{
Vector3 position = this.transform.position;
position.x += -0.1f;
this.transform.position = position;
}
if (Input.GetKey(KeyCode.RightArrow))
{
Vector3 position = this.transform.position;
position.x+= 0.1f;
this.transform.position = position;
}
if (Input.GetKey(KeyCode.UpArrow))
{
Vector3 position = this.transform.position;
position.z+= 0.1f;
this.transform.position = position;
}
if (Input.GetKey(KeyCode.DownArrow))
{
Vector3 position = this.transform.position;
position.z += -0.1f;
this.transform.position = position;
}
}
}
How can I modify this script so that I can use the Standard Assets(Mobile) joysticks to move my player? Any help would be appreciated.
Answer by tanoshimi · Jan 11, 2014 at 07:28 PM
There's a guide here you might find helpful (particularly the section "Double the Joysticks, Double the Fun"):
http://www.raywenderlich.com/25349/how-to-get-started-with-unity-part-23
Thanks for the quick response, but for some reason it wouldnt work for me. I followed everything the tutorial said, but in the end, as soon as i would start the game, the player would just fall. it wouldnt respond to anything.
I finally got it too work, but the right joystick rotates it, and the moving the left joystick to the left or right doesnt do anything. How can i make it so the left joystick fully controls movement?
Your answer
Follow this Question
Related Questions
Hello Im making a Game for mobile and want two floating joysticks one on either side of the screen. 0 Answers
[mobile development] 2D Joystick Controller 0 Answers
How to shoot using the right mobile Joystick? 2 Answers
How do I rotate a character with joystick input in an isometric view? 1 Answer
Rigidbody rotation with virtual joystick, weird behaviour 0 Answers