How to input using tilt/virtual joystick controls?
I can't seem to change to virtual joystick controls nor tilt even though I've change my build to android and imported mobile assets. This is the rolling ball tutorial script to make the ball roll.
So far only wasd keys and arrow keys work, and the virtual joystick I imported into the scene doesn't affect the ball's movement.
I already have an event system in place as well.
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class PlayerController : MonoBehaviour
{
public float speed;
public Text countText;
public Text winText;
private int count;
private Rigidbody rb;
void Start()
{
rb = GetComponent<Rigidbody>();
count = 0;
SetCountText ();
winText.text = " ";
}
void FixedUpdate()
{
//Here is where I think I should change the input to something else.
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
rb.AddForce(movement * speed);
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Pick Up"))
{
other.gameObject.SetActive(false);
count = count + 1;
SetCountText();
}
}
void SetCountText ()
{
countText.text = "Count: " + count.ToString();
if (count >= 6)
{
winText.text = "You Win!";
}
}
}
Answer by persianhercules · Jan 24, 2016 at 11:15 PM
Figured it out. Turns out it was far more complicated than I expected, literally 0 documentation on how to add mobile controls to a preexisting game on 5.0+.
Your answer
Follow this Question
Related Questions
Unity Remote 5 Not working 0 Answers
Change material doesn't work on mobilephone 1 Answer
Touchscreen Controls 0 Answers
my action button wont play in my cell phone android 0 Answers
mobile touch button isnt working HELP! 0 Answers