- Home /
Convert WASD (or arrows) to touch input for ball maze game
Hello, I'm new to Unity. I've got a code that works fine to control a ball with WASD or arrow keys. but i want to be able to move the ball with guitexture arrows. For example, i will have one guiTexture arrow pointing up, and it ideally will apply positive vertical force like the W or upArrow key does. Below is my working code for keyboard controls, but i want it to work for guitexture. Please help me.
Oh, its being developed for android, if that makes any difference.
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour
{
public float speed;
void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
rigidbody.AddForce(movement * speed * Time.deltaTime);
}
Comment
Your answer
Follow this Question
Related Questions
check user touching a particular position or not 2 Answers
Calling Function in other Script via Touch => iOS Crash 1 Answer
GUI texture touch input problem 1 Answer
Multi touches problem 0 Answers