/// <summary> /// 車を操縦する処理 /// ■forward:車の正面方向ベクトル /// ■engineRot:エンジン回転数(速度) /// </summary> /// <param name="forward"></param> /// <param name="engineRot"></param> private void UpdateBaseMove(Vector3 forward, float engineRot) { //符号を取得 //float sign = Mathf.Sign(engineRot); //正面方向に進むベクトルを生成 Vector3 forwardVel = forward; mPreFrameVel = mPreFrameVel.normalized; mSpeed = RigidbodyCalc.GetFloatVelocity(mRigidbody.velocity); Vector3 vel = Vector3.Lerp(mPreFrameVel, forwardVel, mWheelParams.GetGripCoef(mSpeed, mWheelState)); mRigidbody.velocity = vel * engineRot; mPreFrameVel = mRigidbody.velocity; }
/// <summary> /// 車を操縦する処理 /// ■enigneRot:エンジン回転数 /// ■steer:ハンドルからの入力 /// </summary> /// <param name="engineRot"></param> /// <param name="steer"></param> public void UpdateMove(float engineRot, float steer, float brake, bool isGround) { if (isGround) { //前後処理 UpdateBaseMove(mTransform.forward, engineRot); //旋回処理 mTransform.rotation *= mSteeringScript.CalcAddRotValue(steer, mSpeed, mWheelState); //タイヤの状態をドリフト状態に変える処理 mWheelState = mDriftScript.ChangeState(mSpeed, steer, brake, mWheelState); mWheelState = mDriftScript.CancelDrift(mTransform.forward, mRigidbody.velocity, mWheelState); } else { //重力処理 mRigidbody.velocity = RigidbodyCalc.UpdateGravity(mRigidbody.velocity); } }