// Update is called once per frame void Update() { control = (MoveDiscrete)gameObject.GetComponent("MoveDiscrete"); bool up = Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.W); bool down = Input.GetKeyDown(KeyCode.DownArrow) || Input.GetKeyDown(KeyCode.S); bool left = Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.A); bool right = Input.GetKeyDown(KeyCode.RightArrow) || Input.GetKeyDown(KeyCode.D); if (up) control.applyMotion2(MoveDiscrete.DiscMotion.NORTH); if (down) control.applyMotion2(MoveDiscrete.DiscMotion.SOUTH); if (left) control.applyMotion2(MoveDiscrete.DiscMotion.WEST); if (right) control.applyMotion2(MoveDiscrete.DiscMotion.EAST); if(up && right) control.applyMotion2(MoveDiscrete.DiscMotion.NORTH_EAST); if(up && left) control.applyMotion2(MoveDiscrete.DiscMotion.NORTH_WEST); if(down && right) control.applyMotion2(MoveDiscrete.DiscMotion.SOUTH_EAST); if(down && left) control.applyMotion2(MoveDiscrete.DiscMotion.SOUTH_WEST); }
// Use this for initialization void Start() { control = (MoveDiscrete)gameObject.AddComponent ("MoveDiscrete"); controller = new PController (control); if (drawLines) { lines = gameObject.AddComponent<LineRenderer> (); lines.SetWidth (0.1f, 0.1f); lines.material = new Material(Shader.Find("Unlit/Texture")); lines.castShadows = false; lines.receiveShadows = false; lines.SetColors (Color.white, Color.white); } }