public virtual void GetInput() { if (connectedController != null) { inputHorizontal = (Input.GetAxisRaw(connectedController.GetHorizontal())); inputVertical = (Input.GetAxisRaw(connectedController.GetVertical())); trig_active = connectedController.Trig_CheckInput(); a_active = connectedController.A_CheckInput(); b_active = connectedController.B_CheckInput(); x_active = connectedController.X_CheckInput(); y_active = connectedController.Y_CheckInput(); if (inputHorizontal != 0) { FlipSprite(connectedController.GetHorizontal()); } } else { inputHorizontal = Input.GetAxis("Horizontal"); inputVertical = Input.GetAxis("Vertical"); FlipSprite("Horizontal"); } }
// Update is called once per frame void Update() { _attackValLabel.SetText(_input.GetButton(Button.Attack).ToString()); _pullValLabel.SetText(_input.GetButton(Button.Pull).ToString()); _verticalValLabel.SetText((Math.Truncate(_input.GetVertical() * 100) / 100).ToString()); _horizontalValLabel.SetText((Math.Truncate(_input.GetHorizontal() * 100) / 100).ToString()); }
protected override void OnUpdate() { bounce = Mathf.Clamp(bounce + (ControllerInput.GetHorizontal() * Time.deltaTime * GetBouncerSpeed()), -maxScreen, maxScreen); bouncer.transform.position = new Vector3(bounce, bouncerLocation.y, 0); if (ballVelocity.magnitude <= 0) { if (ControllerInput.PressButtonDown()) { StartBall(); } } if (Mathf.Abs(ball.transform.position.x) > 2 || ball.transform.position.y > 8) { //ResetBall(); } ControllerInput.PressMenu(ballVelocity.magnitude <= 0); }
//input is handled here. private void FixedUpdate() { if (trig_active) { if (a_active && a_isEnabled) { Debug.Log(connectedController.GetControllerName() + "A Trigger!"); //Should be empty because the jump ability can't be transmitted. } } else { if (a_active && a_isEnabled) { Debug.Log(connectedController.GetControllerName() + "A"); Jump(); } } #region Physics Celine // MOVING HORIZONTALLY moveHorizontal = (Input.GetAxis(connectedController.GetHorizontal())); if (grounded) { rigidBody2D.velocity = new Vector2(moveHorizontal * speed, rigidBody2D.velocity.y); charAnimation.SetBool("PlayerWalk", true); charAnimation.SetBool("StoodStill", false); } else { // If player turns mid-jump if (tempMove > 0.01 && moveHorizontal < -0.01) { rigidBody2D.velocity = new Vector2(moveHorizontal * speed * 0.3f, rigidBody2D.velocity.y); } else if (tempMove < -0.01 && moveHorizontal > 0.01) { rigidBody2D.velocity = new Vector2(moveHorizontal * speed * 0.3f, rigidBody2D.velocity.y); } } if (moveHorizontal > -.07 && moveHorizontal < .07) { charAnimation.SetBool("PlayerWalk", false); } if (Input.GetAxisRaw(connectedController.GetHorizontal()) == 0) { charAnimation.SetBool("StoodStill", true); } if (moveHorizontal < -.25) { if (graphicsSlot.localScale.x > 0) { graphicsSlot.localScale = new Vector3(-graphicsSlot.localScale.x, graphicsSlot.localScale.y, graphicsSlot.localScale.z); pickupSlot.localPosition = new Vector3(-pickupSlot.localPosition.x, pickupSlot.localPosition.y, pickupSlot.localPosition.z); } } if (moveHorizontal > .25) { if (graphicsSlot.localScale.x < 0) { graphicsSlot.localScale = new Vector3(-graphicsSlot.localScale.x, graphicsSlot.localScale.y, graphicsSlot.localScale.z); pickupSlot.localPosition = new Vector3(-pickupSlot.localPosition.x, pickupSlot.localPosition.y, pickupSlot.localPosition.z); } } /* * if(facingRight) { * graphicsSlot.localScale = new Vector3(1, graphicsSlot.localScale.y, graphicsSlot.localScale.z); * } * else if(!facingRight) { * graphicsSlot.localScale = new Vector3(-1, graphicsSlot.localScale.y, graphicsSlot.localScale.z); * } */ // CLIMBING moveVertical = (Input.GetAxis(connectedController.GetVertical())); if (climbable) { charAnimation.SetBool("PlayerWalk", false); if (!grounded) { rigidBody2D.velocity = new Vector2(moveHorizontal * speed / 3, moveVertical * speed); audioManager.interactionSound(interactionSounds.stairs); } else { rigidBody2D.velocity = new Vector2(moveHorizontal * speed, moveVertical * speed); } } }
protected override void OnUpdate() { if (playing) { if (ControllerInput.PressButtonDown() && !shot) { shot = true; SpawnBullet(); } if (shot) { shootTimer += Time.deltaTime; if (shootTimer >= rateOfFire) { shot = false; shootTimer = 0; } } ship.Rotate(Vector3.back * ControllerInput.GetHorizontal() * rotationSpeed * Time.deltaTime); if (ship.position.x < -9) { ship.position += Vector3.right * 18; } if (ship.position.x > 9) { ship.position += Vector3.left * 18; } if (ship.position.y > 6) { ship.position += Vector3.down * 7.5f; } if (ship.position.y < -1.5) { ship.position += Vector3.up * 7.5f; } for (int i = 0; i < asteroids.Length; i++) { if (asteroids[i].gameObject.activeSelf) { asteroids[i].GetComponent <Asteroid>().UpdateAsteroid(); } } } else { if (ControllerInput.PressButtonUp()) { failScreen.SetActive(false); playing = true; numAsteroids = 2; SetupAsteroids(); SetupShip(); shootTimer = 0; shot = false; } } }