void MoveInput() { moveVector = new Vector3(rewiredPlayer.GetAxis("Strafe"), 0, rewiredPlayer.GetAxis("Walk")); //Push that to the model mechModel.Accelerate(moveVector); }
void KeyInput() { // var x = Input.GetAxis("Horizontal"); // var z = Input.GetAxis("Vertical"); var x = _player.GetAxis("Move Horizontal"); var z = _player.GetAxis("Move Vertical"); var dir = new Vector3(x, 0, z); Move(dir); if (dir.sqrMagnitude > 0.1f) { _animationController.Run(); } else { _animationController.Idle(); } if (_player.GetButtonDown("Mine")) { Attack(); _animationController.Mine(); } if (_player.GetButtonDown("GrabAndThrow") || Input.GetKeyDown(_grabButton)) { GrabAction(); } }
protected override void FixedUpdate() { var horizontal = _player.GetAxis("Horizontal"); var vertical = _player.GetAxis("Vertical"); _carController.Steer(vertical, horizontal); }
void Update() { //Makes the axis like a button and only moved once if (player.GetAxis("LSV") != 0) { if (!axisActive) { MoveCursor(); axisActive = true; } } if (player.GetAxis("LSV") == 0) { axisActive = false; axisValue = 0f; } if (player.GetButtonDown("A")) { switch (menuState) { case 0: PlayGame(); break; case 1: GameOptions(); break; case 2: QuitGame(); break; } } }
void detectControl() { float xAxis = rePlayer.GetAxis("Horizontal"); float yAxis = rePlayer.GetAxis("Vertical"); rigid.velocity = Vector2.MoveTowards(rigid.velocity, new Vector2(velocity * xAxis, velocity * yAxis), softVelocity * Time.deltaTime); Flip(); if (rePlayer.GetButtonDown("Leave") || rePlayer.GetButtonDown("PickUp")) { RaycastHit2D[] rch = Physics2D.BoxCastAll((Vector2)transform.position + box.offset, box.size, 0, Vector3.down, boxCastDistance, skelletonLayer); foreach (RaycastHit2D r in rch) { BasicPlayer bp = r.collider.GetComponent <BasicPlayer>(); if (bp == null || bp.ghost != null || bp.health <= 0 || bp.stamina < 3) { continue; } bp.ghost = this; transform.SetParent(bp.gameObject.transform); transform.localPosition = Vector3.zero; anim.SetTrigger("Possess"); bp.anim.SetTrigger("Alive"); this.enabled = false; rigid.velocity = Vector2.zero; free = false; return; } lightTime = 1; } }
void Move() { if (onPortal) { moveSpeed = baseSpeed / 2; } else { moveSpeed = baseSpeed; } if (!isHit) { rbd2.velocity = new Vector2(Mathf.Lerp(0, player.GetAxis("MoveHorizontal") * moveSpeed, 0.8f), Mathf.Lerp(0, player.GetAxis("MoveVertical") * moveSpeed, 0.8f)); } else { rbd2.AddForce(new Vector2(player.GetAxis("MoveHorizontal") * moveSpeed, player.GetAxis("MoveVertical") * moveSpeed)); hitDuration -= 1f; if (hitDuration < 0) { isHit = false; } } }
void GetInput() { InputActions.moveVector.x = player.GetAxis("Rotate Y"); InputActions.moveVector.z = player.GetAxis("Rotate X"); InputActions.moveVector.y = player.GetAxis("Rotate Z"); InputActions.restart_game = player.GetButtonDown("Restart"); }
// Update is called once per frame void Update() { if (GameManager.Instance.CurrentState != GameManager.GAME_STATE.RUNNING) { if (GameManager.Instance.CurrentState != GameManager.GAME_STATE.PAUSED) { return; } } if (!inputActive) { return; } // Axes horizontalAxis = player.GetAxis(RewiredConsts.Action.HorizontalAxis); verticalAxis = player.GetAxis(RewiredConsts.Action.VerticalAxis); // Buttons powerupDown = player.GetButtonDown(RewiredConsts.Action.Powerup); pauseDown = player.GetButtonDown(RewiredConsts.Action.Pause); if (pauseDown) { GameManager.Instance.PauseGame(controller); } }
private void CursorMovement() { float horizontal = 0; horizontal = inputPlayer.GetAxis("HorizontalMove"); float vertical = 0; vertical = inputPlayer.GetAxis("VerticalMove"); Vector2 actualPosition = cursor.rectTransform.anchoredPosition; actualPosition.x += horizontal * moveSpeedValue * Time.deltaTime * 100; actualPosition.y += vertical * moveSpeedValue * Time.deltaTime * 100; if (actualPosition.x < leftMax) { actualPosition.x = leftMax; } else if (actualPosition.x > rightMax) { actualPosition.x = rightMax; } if (actualPosition.y < DownMax) { actualPosition.y = DownMax; } else if (actualPosition.y > UpMax) { actualPosition.y = UpMax; } cursor.rectTransform.anchoredPosition = actualPosition; }
// Update is called once per frame void FixedUpdate() { var horiz = player.GetAxis(hAxis); var vert = player.GetAxis(vAxis); GetComponent <Rigidbody2D>().AddForce(new Vector2(horiz, vert) * handSpeed); }
void Update() { joyaxeX = _rewiredPlayer.GetAxis("Horizontal"); joyaxeY = _rewiredPlayer.GetAxis("Vertical"); Vector2 dir_Move = Vector2.zero; if (joyaxeX == Mathf.Clamp(joyaxeX, -0.9f, 0.9f) && joyaxeY == Mathf.Clamp(joyaxeY, -0.9f, 0.9f)) { test = true; dir_Move.x = joyaxeX; dir_Move.y = joyaxeY; player.speedMax = walk; } else { test = false; dir_Move.x = joyaxeX; dir_Move.y = joyaxeY; player.speedMax = run; } if (Input.GetKeyDown(KeyCode.Space)) { player.Dash(); } if (animator != null) { animator.SetFloat("MoveX", -dir_Move.x); animator.SetFloat("MoveY", dir_Move.y); animator.SetBool("Moving", dir_Move != Vector2.zero); } player.MoveDir(dir_Move); }
private void GetInput() { moveVector.x = player.GetAxis("Move Horizontal"); moveVector.y = player.GetAxis("Move Vertical"); chargeRe = player.GetButton("Charge"); start = player.GetButton("Start"); escape = player.GetButton("Escape"); }
private void GetInput() { moveVector.x = player.GetAxis("MoveX"); moveVector.y = player.GetAxis("MoveY"); moveVector.z = player.GetAxis("MoveZ"); lookVector.x += player.GetAxis("LookX"); lookVector.y += player.GetAxis("LookY"); }
// Update is called once per frame void Update() { // Get button presses from controller moveAxes = new Vector2(player.GetAxis("MoveHorizontal"), player.GetAxis("MoveVertical")); interact = player.GetButtonDown("Interact"); escape = player.GetButtonDown("Escape"); }
private void GetInput() { _turnVector.x = _player.GetAxis("Turn Horizontal"); _turnVector.y = _player.GetAxis("Turn Vertical"); _moveVector.x = _player.GetAxis("Move Horizontal"); _moveVector.y = _player.GetAxis("Move Vertical"); }
void GetInput() { _moveVec3.x = _player.GetAxis("MoveX"); _moveVec3.z = _player.GetAxis("MoveZ"); _lookVec3.x = _player.GetAxis("Look Horizontal"); _lookVec3.y = _player.GetAxis("Look Vertical"); _fire = _player.GetButtonDown("Fire"); }
private void GetInput() { // Get the input from the Rewired Player. All controllers that the Player owns will contribute, so it doesn't matter // whether the input is coming from a joystick, the keyboard, mouse, or a custom controller. moveVector.x = player.GetAxis("Move Horizontal"); // get input by name or action id moveVector.y = player.GetAxis("Move Vertical"); }
//Not being used void PlayerLogIn(Rewired.Player player, int playerId) { //Advances the player through the menu if (player.GetButtonDown("A")) { buttonClickSound.PlayOneShot(buttonClick, 1f); menuState++; MenuState(); } //Regress the player through the menu if (player.GetButtonDown("B")) { buttonClickSound.PlayOneShot(buttonClick, 1f); menuState--; MenuState(); } //Returns "buttons" to their original color if (player.GetAxis("LSH") == 0) { p1AxisActive = false; roundRightArrow.GetComponent <Graphic>().color = roundArrowNormalColor; roundLeftArrow.GetComponent <Graphic>().color = roundArrowNormalColor; } //Selects next button if (player.GetAxis("LSH") == -1 || player.GetAxis("LSH") == 1) { if (!p1AxisActive) { //Only let the player change the round number if (menuState == 0) { //Changes the color of the correct button if (player.GetAxis("LSH") == -1)// && playerId == 0) { roundLeftArrow.GetComponent <Graphic>().color = roundArrowHighlightedColor; buttonClickSound.PlayOneShot(buttonClick, 1f); } if (player.GetAxis("LSH") == 1)// && playerId == 0) { roundRightArrow.GetComponent <Graphic>().color = roundArrowHighlightedColor; buttonClickSound.PlayOneShot(buttonClick, 1f); } } //Only let the player change the level if (menuState == 1) { } p1AxisActive = true; } } }
void ApplyPlayerInputs() { if (_player == null) { return; } moveInput = new Vector2(_player.GetAxis("moveX"), _player.GetAxis("moveY")); fireInput = new Vector2(_player.GetAxis("fireX"), _player.GetAxis("fireY")); _alphaAction = _player.GetButtonDown("alpha"); }
private void UpdateCamView() { float mouseX = playerController.GetAxis("LookX") * mouseSensitivity * Time.deltaTime; float mouseY = playerController.GetAxis("LookY") * mouseSensitivity * Time.deltaTime; xRotation -= mouseY; xRotation = Mathf.Clamp(xRotation, -90, 90); playerCamera.transform.localRotation = Quaternion.Euler(xRotation, 0, 0); transform.Rotate(Vector3.up, mouseX); }
private void GetInput() { if (_player == null) { return; } _acceleratorPedal = _player.GetAxis("Accelerator"); _brakePedal = _player.GetAxis("Brake"); _steeringWheel = _player.GetAxis("Steer") * Math.Abs(_player.GetAxis("Steer")); }
private void UpdateInputs() { //input_horizontal = Input.GetAxis("Horizontal"); //input_vertical = Input.GetAxis("Vertical"); input_horizontal = rewiredPlayer.GetAxis("MHorizontal"); input_vertical = rewiredPlayer.GetAxis("MVertical"); input_look_horizontal = rewiredPlayer.GetAxis("LHorizontal"); input_look_vertical = rewiredPlayer.GetAxis("LVertical"); //bool newInteract = Input.GetAxis("Submit") != 0.0f; input_interacting = rewiredPlayer.GetButton("Interact"); }
// Update is called once per frame void Update() { if (disableMovement) { return; } // Movement Vector3 moveVec = new Vector3 { x = rePlayer.GetAxis("LStick Horizontal"), z = rePlayer.GetAxis("LStick Vertical") }; moveVec = Quaternion.AngleAxis(moveDirectionOffset, Vector3.up) * moveVec; cc.Move(moveVec * moveSpeed * Time.deltaTime); // Rotation // Get stick direction Vector3 lookVector = new Vector3 { x = rePlayer.GetAxis("RStick Horizontal") * -1, y = rePlayer.GetAxis("RStick Vertical") }; if (lookVector.sqrMagnitude > 0) { // Convert look vector to an angle float __y = Vector2.SignedAngle((new Vector2(-0.5f, 0.5f)), lookVector); __y += 45.0f + moveDirectionOffset; // Set public facing vars lookDirection = new Vector3 { x = lookVector.x, y = lookVector.y }; lookRotation = new Vector3 { y = __y }; // If applying to transform if (applyLookRotationToTransform) { cc.transform.rotation = Quaternion.Euler(0, __y, 0); } } }
private void PlayerMove() { input = new Vector2(inputManager.GetAxis("Horizontal"), inputManager.GetAxis("Vertical")); bool isMoving = input.magnitude > .2f; if (!isMoving) { input = Vector2.zero; } else if (!IsDashing() && CanAfford(dashPrice)) { if (input != Vector2.zero && inputManager.GetButtonDown("Dash")) { Pay(dashPrice); dashTimeRemaining = dashDuration; dashEffect.Play(); } } bool wu = false, wr = false, wd = false, wl = false; if (input != Vector2.zero && !choicePopup.IsVisible) { if (Mathf.Abs(input.x) > Mathf.Abs(input.y)) { // X stringer than Y wl = !(wr = input.x > 0); } else { wd = !(wu = input.y > 0); } } if (IsDashing()) { input = input * dashCoefficient; dashTimeRemaining -= Time.deltaTime; } _animator.SetBool("IsWalkingUp", wu); _animator.SetBool("IsWalkingRight", wr); _animator.SetBool("IsWalkingDown", wd); _animator.SetBool("IsWalkingLeft", wl); _animator.SetBool("IsRunningLeft", IsRunning && wl); _animator.SetBool("IsRunningRight", IsRunning && wr); _animator.speed = isMoving ? input.magnitude : 1; }
private void DoInput() { if (inputBlocked) { return; } if (rePlayer.GetAxis("LStick Horizontal") != 0) { float newY = Mathf.Sin(Time.time * 10) / 10; playerObject.transform.localPosition = new Vector3(playerObject.transform.localPosition.x, newY, playerObject.transform.localPosition.z); float newX = Mathf.Sin(Time.time * 10) / 400; handObject.transform.localPosition = new Vector3(newX, handObject.transform.localPosition.y, handObject.transform.localPosition.z); } // Activate all actions if they exist foreach (KeyValuePair <string, PlayerUsable> action in actionMap) { if (rePlayer.GetButton(action.Key)) { action.Value.Use(); } else if (rePlayer.GetButtonUp(action.Key)) { action.Value.UnUse(); } else if (rePlayer.GetButtonDown(action.Key)) { action.Value.UseOnce(); } } }
/// <summary> /// Listen for user input. /// </summary> private void ListerForDirectionInput() { float deltaY = _rePlayer.GetAxis("MoveVertical"); if (deltaY > 0f) { LostFocus(); prev.OnFocus(); } if (deltaY < 0f) { LostFocus(); next.OnFocus(); } if (_rePlayer.GetButtonDown("Action")) { Selected(); } if (_rePlayer.GetButtonDown("Cancel")) { Canceled(); } }
/// <summary> /// Move player. /// </summary> private void MovePlayer() { float deltaZ = -(_rePlayer.GetAxis("MoveHorizontal") * speed); float deltaX = _rePlayer.GetAxis("MoveVertical") * speed; Vector3 movement = new Vector3(deltaX, 0f, deltaZ); movement = Vector3.ClampMagnitude(movement, speed); this.isMoving = (movement.magnitude > 0f) ? true : false; movement.y = gravity; orientator.localPosition = new Vector3(movement.z, 0f, -movement.x); controller.Move(movement * Time.deltaTime); }
public static int GetAxis(uint index, Axis axis) { #if USE_REWIRED RE.Player player = RE.ReInput.players.GetPlayer((int)index); float value = player.GetAxis(AxisToRewiredAction(axis)); return(value <0.0f ? -1 : value> 0.0f ? 1 : 0); #else // USE_REWIRED switch (axis) { case Axis.MoveHorizontal: if (HoriDirKeyHeld(index)) { return(GetHoriKeyDir(index)); } break; case Axis.AimVertical: if (VertDirKeysHeld(index)) { return(GetVertKeyDir(index)); } break; } Xbox360Axis?axis360 = AxisTo360(axis); return(axis360 == null ? 0 : GetXboxAxis(index, axis360.Value)); #endif // USE_REWIRED }
// Update is called once per frame void Update() { velocity = body.GetRelativePointVelocity(relative_point); mag = velocity.magnitude; float topSpeed = FORWARD_BOOST_FLAG ? TOP_SPEED * 2f : TOP_SPEED; if (mag > topSpeed) { body.velocity = velocity.normalized * topSpeed; } body.AddForce(Vector2.up * FORCE_APPLIED * player.GetAxis(RewiredConsts.Action.MOVEVERTICAL)); body.AddForce(Vector2.right * FORCE_APPLIED * player.GetAxis(RewiredConsts.Action.MOVEHORIZONTAL)); body.AddForce(Vector2.right * CONSTANT_SCROLL_FORCE); if (player.GetButtonDown(RewiredConsts.Action.SWIM) && Time.time - boostTime > BOOST_COOLDOWN) { boostTime = Time.time; AkSoundEngine.PostEvent("FishSpeedBurst", gameObject); } if (player.GetButton(RewiredConsts.Action.SWIM) && Time.time - boostTime < BOOST_DURATION) { body.AddForce(Vector2.right * BOOST_FORCE); FORWARD_BOOST_FLAG = true; var emission = bubbleTrail.emission; emission.enabled = true; } else { FORWARD_BOOST_FLAG = false; var emission = bubbleTrail.emission; emission.enabled = false; } if (player.GetButtonDown(RewiredConsts.Action.FIRE)) { if (prawns.Count > 0) { prawns[prawns.Count - 1].Shoot(transform.position + Vector3.right * 0.1f, Vector3.right); prawns.RemoveAt(prawns.Count - 1); Game.Instance.player.ShrimpCount = prawns.Count; AkSoundEngine.PostEvent("ShrimpCanon", gameObject); } } }
private void HandleInput() { _horizontal += _player.GetAxis(InputActions.Horizontal); _vertical += _player.GetAxis(InputActions.Vertical); _isSwitchLeftPressed = _isSwitchLeftPressed || _player.GetButtonDown(InputActions.SwitchLeft); _isSwitchLeftReleased = _isSwitchLeftReleased || _player.GetButtonUp(InputActions.SwitchLeft); _isSwitchLeftHeld = _isSwitchLeftHeld || _player.GetButton(InputActions.SwitchLeft); _isSwitchRightPressed = _isSwitchRightPressed || _player.GetButtonDown(InputActions.SwitchRight); _isSwitchRightReleased = _isSwitchRightReleased || _player.GetButtonUp(InputActions.SwitchRight); _isSwitchRightHeld = _isSwitchRightHeld || _player.GetButton(InputActions.SwitchRight); _isShootPressed = _isShootPressed || _player.GetButtonDown(InputActions.Shoot); _isShootReleased = _isShootReleased || _player.GetButtonUp(InputActions.Shoot); _isShootHeld = _isShootHeld || _player.GetButton(InputActions.Shoot); }