Hi guys, having a bit of difficulty with this one, I am new to programming and unity ect…
Basically, what I want is a space ship in the middle of the screen (With 2D editor and sprites) with 6 buttons around the object.
If you click on the top right button, the ship faces that way and shoots in that direction, if you click the bottom button, it faces that way and shoots.
We don’t have to worry about the shooting part, that should be easy, but I am having difficulty linking the buttons with the object and making it face in the direction of the button that is being clicked.
All I have currently is a small script that if you press A, it turns to the leftish, if you press W, it faces upwards, but this is really not ideal haha also I can’t get S to work. This is what I have which is not what I want haha, any help would be appreciated
I hope I am making sense
using UnityEngine;
using System.Collections;
public class Move : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown (KeyCode.D)) {
transform.right = new Vector3 (-1, -1, 0);
}
else if (Input.GetKeyDown (KeyCode.W)) {
transform.right = new Vector3 (1, 0, 0);
}
else if (Input.GetKeyDown (KeyCode.S)) {
transform.right = new Vector3 (1, 0, 0); //Can't get this to work????
}
else if (Input.GetKeyDown (KeyCode.Q)) {
transform.right = new Vector3 (1, 1, 0);
}
else if (Input.GetKeyDown (KeyCode.E)) {
transform.right = new Vector3 (1, -1, 0);
}
else if (Input.GetKeyDown (KeyCode.A)) {
transform.right = new Vector3 (-1, 1, 0);
}
}
}