1 using UnityEngine;
2 using System.Collections;
3
4 public class Player1 : MonoBehaviour {
5
6 public static bool selected = true;
7 public int translateSpeed=1;
8 public int rotateSpeed = 10;
9
10 // Use this for initialization
11 void Start () {
12
13 }
14
15 // Update is called once per frame
16 void Update () {
17 if (Input.GetKeyDown (KeyCode.P)) {
18 selected = !selected;
19 }
20 }
21
22 void OnGUI(){
23 if (selected) {
24 // turn left
25 if (Input.GetKey (KeyCode.A)) {
26 transform.Translate (Vector3.left * Time.deltaTime);
27 }
28
29 // turn right
30 if (Input.GetKey (KeyCode.D)) {
31 transform.Translate (Vector3.right * Time.deltaTime);
32 }
33
34 // turn forward
35 if (Input.GetKey (KeyCode.W)) {
36 transform.Translate (Vector3.forward * Time.deltaTime);
37 }
38
39 // turn backward
40 if (Input.GetKey (KeyCode.S)) {
41 transform.Translate (Vector3.back * Time.deltaTime);
42 }
43
44 // turn up
45 if (Input.GetKey (KeyCode.Q)) {
46 transform.Translate (Vector3.up * Time.deltaTime);
47 }
48
49 // turn down
50 if (Input.GetKey (KeyCode.E)) {
51 transform.Translate (Vector3.down * Time.deltaTime);
52 }
53
54 // rotate x axis anticlockwise
55 if (Input.GetKey (KeyCode.H)) {
56 transform.Rotate (Vector3.left * Time.deltaTime * rotateSpeed);
57 }
58
59 // rotate x axis clockwise
60 if (Input.GetKey (KeyCode.K)) {
61 transform.Rotate (Vector3.right * Time.deltaTime * rotateSpeed);
62 }
63
64 // rotate z axis clockwise
65 if (Input.GetKey (KeyCode.U)) {
66 transform.Rotate (Vector3.forward * Time.deltaTime * rotateSpeed);
67 }
68
69 // rotate z axis anticlockwise
70 if (Input.GetKey (KeyCode.J)) {
71 transform.Rotate (Vector3.back * Time.deltaTime * rotateSpeed);
72 }
73
74 // rotate y axis clockwise
75 if (Input.GetKey (KeyCode.Y)) {
76 transform.Rotate (Vector3.up * Time.deltaTime * rotateSpeed);
77 }
78
79 // rotate y axis anticlokcwise
80 if (Input.GetKey (KeyCode.I)) {
81 transform.Rotate (Vector3.down * Time.deltaTime * rotateSpeed);
82 }
83 }
84 }
85 }