Hi all
I have a script that currently allows gives me keyboard input to move an object within my scene, like so
public class PlaneMovement : MonoBehaviour {
public float moveSpeed = 10.0f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
public void Update () {
transform.Translate(Vector3.up * Input.GetAxis("Vertical") * Time.deltaTime * moveSpeed);
if (Input.GetKey (KeyCode.W))
{
transform.Rotate (Vector3.right, Space.Self);
}
if (Input.GetKey (KeyCode.S))
{
transform.Rotate (Vector3.left, Space.Self);
}
if (Input.GetKey (KeyCode.RightArrow))
{
transform.Rotate (Vector3.up, Space.Self);
}
if (Input.GetKey (KeyCode.LeftArrow))
{
transform.Rotate (Vector3.down, Space.Self);
}
if (Input.GetKey (KeyCode.A))
{
transform.Rotate (Vector3.back, Space.Self);
}
if (Input.GetKey (KeyCode.D))
{
transform.Rotate (Vector3.forward, Space.Self);
}
}
}
Now I'd like to create an extremely simple interface to test my scene on a tablet device, so just 8 sprites in a line (or even just 1 to start off with), each of which will reference one of the keys above.
I've created the sprites, attached UIButton scripts and colliders and tried writing a new script with individual void functions, each referencing one of the above buttons, but no luck working (i'm testing initially with just the mouse).
Can anyone point me in the direction or provide an example of how I can add to this current code to get the result I'm looking for? I have a feeling it's to do with 'delegates' but the Microsoft explanation on this was far too complicated for me sadly.
Thanks in advance