private void ApplyStickPosition(Vector2 stickPos) { var pos = new Vector2( stickPos.x * (ReverseGamepadStickLeanHorizontal ? -1f : 1f), stickPos.y * (ReverseGamepadStickLeanVertical ? -1f : 1f) ); _rawStickPos = pos; _gamePad.SetHorizontalPosition(pos); (_rawLeftPos, _rawLeftRot) = _gamePad.GetLeftHand(); (_rawRightPos, _rawRightRot) = _gamePad.GetRightHand(); }
public override void Update() { UpdateButtonDownYOffset(); _timeJitter.Update(Time.deltaTime, _waitingBody.Phase); _inputJitter.Update(Time.deltaTime); //とりあえずLerp _filterStickPos = Vector2.Lerp(_filterStickPos, _rawStickPos, SpeedFactor * Time.deltaTime); //いろいろな理由で後処理が載るのを計算: ただし手が乗っかってないとリセットされていく if (HandIsOnController) { _posOffset = _setting.imageBasedBodyMotion.BodyIkOffset * BodyMotionToGamepadPosApplyFactor + _posOffsetScale * ( Vector3.up * _offsetY + _timeJitter.PosOffset + _inputJitter.PosOffset ); _rotOffset = _timeJitter.Rotation * _inputJitter.Rotation; } else { _posOffset = Vector3.Lerp(_posOffset, Vector3.zero, OffsetResetLerpFactor * Time.deltaTime); _rotOffset = Quaternion.Slerp(_rotOffset, Quaternion.identity, OffsetResetLerpFactor * Time.deltaTime); } //フィルタリングとオフセットを考慮してゲームパッドの位置自体を調整 _gamePad.SetFilteredPositionAndRotation(_filterStickPos, _posOffset, _rotOffset); //調整後のコントローラ位置に合わせて手を持っていく var(leftPos, leftRot) = _gamePad.GetLeftHand(); var(rightPos, rightRot) = _gamePad.GetRightHand(); _leftHand.Position = leftPos; _leftHand.Rotation = leftRot; _rightHand.Position = rightPos; _rightHand.Rotation = rightRot; }