private void Update() { _velocity *= 0; if (_gamepadManager.GetStickPosX(0) > _deadZoneStick) { _acceleration += Time.deltaTime * _accelerationSpeed; if (_acceleration > _speed) { _acceleration = _speed; } _velocity += Vector2.right * _acceleration * Time.deltaTime; _rigidBody.velocity += _velocity; } else if (_gamepadManager.GetStickPosX(0) < -_deadZoneStick) { _acceleration += Time.deltaTime * _accelerationSpeed; if (_acceleration > _speed) { _acceleration = _speed; } _velocity -= Vector2.right * _acceleration * Time.deltaTime; _rigidBody.velocity += _velocity; } else { _acceleration = 0; _velocity = _rigidBody.velocity; _velocity.x = Mathf.Lerp(_velocity.x, 0, _decelerationSpeed * Time.deltaTime); _rigidBody.velocity = _velocity; } if (_gamepadManager.AButtonPressed(0)) { _rigidBody.velocity += Vector2.up * _jumpHigh; } }
private void Update() { _lerpTime = (Mathf.Sin(Time.time * _lerpSpeed) + 1) / 2; alltext[_currentIndex].color = Color.Lerp(_baseColor, _selectedColor, _lerpTime); if (_fadeOut) { return; } if (_gamepadManager.AButtonPressed(0)) { ExecuteButton(); return; } if (!_hasMoved) { CheckGamepadMove(); } else { if (_gamepadManager.GetStickPosY(0) > -_stickDeadZone && _gamepadManager.GetStickPosY(0) < _stickDeadZone) { _currentMoveTime = 0; _hasMoved = false; return; } _currentMoveTime += Time.deltaTime; if (_currentMoveTime >= _maxMoveTime) { _currentMoveTime = 0; _hasMoved = false; } } }
private void Update() { if (_canMove) { if (useGamepad) { #region ExampleGamepad //Debug.Log(_gamepadManager.GetStickPosX(_indexPlayer)); //Debug.Log(_gamepadManager.GetStickPosY(_indexPlayer)); if (_gamepadManager.AButtonPressed(_indexPlayer)) { Debug.Log("A Button Pressed"); } if (_gamepadManager.BButtonPressed(_indexPlayer)) { Debug.Log("B Button Pressed"); } if (_gamepadManager.XButtonPressed(_indexPlayer)) { Debug.Log("X Button Pressed"); } if (_gamepadManager.YButtonPressed(_indexPlayer)) { Debug.Log("Y Button Pressed"); } if (_gamepadManager.LeftTriggerPressed(_indexPlayer)) { Debug.Log("Left Trigger Pressed"); } if (_gamepadManager.RightTriggerPressed(_indexPlayer)) { Debug.Log("Right Trigger Pressed"); } if (_gamepadManager.LeftShoulderPressed(_indexPlayer)) { Debug.Log("Left Shoulder Pressed"); } if (_gamepadManager.RightShoulderPressed(_indexPlayer)) { Debug.Log("Right Shoulder Pressed"); } #endregion } if (useKeyboard) { if (_inputManager.GetSpaceBarPressed()) { Debug.Log("Space Bar Pressed"); } if (_inputManager.GetSpaceBarReleased()) { Debug.Log("Space Bar Released"); } if (_inputManager.GetSpaceBarState()) { Debug.Log("Space Bar Input"); } // EXAMPLE Vector3 direction = Vector3.zero; if (_inputManager.GetForwardState()) { direction += transform.forward; } if (_inputManager.GetBackwardState()) { direction -= transform.forward; } if (_inputManager.GetRightState()) { direction += transform.right; } if (_inputManager.GetLeftState()) { direction -= transform.right; } direction.Normalize(); _rigidBody.MovePosition(transform.position + direction * Time.deltaTime * speed); } } }