public void Attack() { transform.position = transform.position; pawn.mover.Move(Vector3.zero); transform.LookAt(chaseTarget.transform); if (Time.time > stateStartTime + pawn.shootWait) { GameObject bullet = Instantiate(pawn.bulletPrefab, pawn.bulletSpawn.transform.position, pawn.bulletSpawn.transform.rotation); bulletMover bm = bullet.GetComponent <bulletMover>(); bm.SetPlayer(pawn); } }
// Update is called once per frame void Update() { //Tell the mover that I am not moving Vector3 directionToMove = Vector3.zero; //if the player presses W if (Input.GetKey(KeyCode.UpArrow)) { //tell the move to move in a forward direction directionToMove += Vector3.forward; } //if the player presses S if (Input.GetKey(KeyCode.DownArrow)) { //tell the move to move in a backward direction directionToMove -= Vector3.forward; } //if the player presses A if (Input.GetKey(KeyCode.LeftArrow)) { //tell the mover to rotate in a leftward direction data.mover.Rotate(-data.rotateSpeed * Time.deltaTime); } //if the player presses D if (Input.GetKey(KeyCode.RightArrow)) { //tell the move to rotate in a rightward direction data.mover.Rotate(data.rotateSpeed * Time.deltaTime); } //if the player presses space bar if (Input.GetKeyDown(KeyCode.Keypad0)) { GameObject bullet = Instantiate(data.bulletPrefab, data.bulletSpawn.transform.position, data.bulletSpawn.transform.rotation); bulletMover bm = bullet.GetComponent <bulletMover>(); bm.SetPlayer(data); } data.mover.Move(directionToMove); }