// Token: 0x06000C94 RID: 3220 RVA: 0x00038CCC File Offset: 0x00036ECC
 private void FixedUpdate()
 {
     this.UpdateCenterOfMass();
     this.UpdateAllWheelParameters();
     if (this.inputBank)
     {
         Vector3 moveVector = this.inputBank.moveVector;
         Vector3 normalized = Vector3.ProjectOnPlane(this.inputBank.aimDirection, base.transform.up).normalized;
         float   num        = Mathf.Clamp(Util.AngleSigned(base.transform.forward, normalized, base.transform.up), -this.maxSteerAngle, this.maxSteerAngle);
         float   magnitude  = moveVector.magnitude;
         foreach (HoverVehicleMotor.AxleGroup axleGroup in this.staticAxles)
         {
             HoverEngine leftWheel  = axleGroup.leftWheel;
             HoverEngine rightWheel = axleGroup.rightWheel;
             this.ApplyWheelForces(leftWheel, magnitude, axleGroup.isDriven, axleGroup.slidingTractionCurve);
             this.ApplyWheelForces(rightWheel, magnitude, axleGroup.isDriven, axleGroup.slidingTractionCurve);
         }
         foreach (HoverVehicleMotor.AxleGroup axleGroup2 in this.steerAxles)
         {
             HoverEngine leftWheel2     = axleGroup2.leftWheel;
             HoverEngine rightWheel2    = axleGroup2.rightWheel;
             float       num2           = this.maxTurningRadius / Mathf.Abs(num / this.maxSteerAngle);
             float       num3           = Mathf.Atan(this.wheelBase / (num2 - this.trackWidth / 2f)) * 57.29578f;
             float       num4           = Mathf.Atan(this.wheelBase / (num2 + this.trackWidth / 2f)) * 57.29578f;
             Quaternion  localRotation  = Quaternion.Euler(0f, num3 * Mathf.Sign(num), 0f);
             Quaternion  localRotation2 = Quaternion.Euler(0f, num4 * Mathf.Sign(num), 0f);
             if (num <= 0f)
             {
                 leftWheel2.transform.localRotation  = localRotation;
                 rightWheel2.transform.localRotation = localRotation2;
             }
             else
             {
                 leftWheel2.transform.localRotation  = localRotation2;
                 rightWheel2.transform.localRotation = localRotation;
             }
             this.ApplyWheelForces(leftWheel2, magnitude, axleGroup2.isDriven, axleGroup2.slidingTractionCurve);
             this.ApplyWheelForces(rightWheel2, magnitude, axleGroup2.isDriven, axleGroup2.slidingTractionCurve);
         }
         Debug.DrawRay(base.transform.position, normalized * 5f, Color.blue);
     }
 }
        // Token: 0x06000CC7 RID: 3271 RVA: 0x0003F628 File Offset: 0x0003D828
        private void Simulate(float deltaTime)
        {
            Quaternion quaternion = Quaternion.Euler(0f, this.yaw, 0f);

            if (this.hasEffectiveAuthority)
            {
                if (this.driveFromRootRotation)
                {
                    Quaternion rhs = this.rootMotionAccumulator.ExtractRootRotation();
                    if (this.targetTransform)
                    {
                        this.targetTransform.rotation = quaternion * rhs;
                        float y = this.targetTransform.rotation.eulerAngles.y;
                        this.yaw = y;
                        float angle = 0f;
                        if (this.moveVector.sqrMagnitude > 0f)
                        {
                            angle = Util.AngleSigned(Vector3.ProjectOnPlane(this.moveVector, Vector3.up), this.targetTransform.forward, -Vector3.up);
                        }
                        int num = CharacterDirection.PickIndex(angle);
                        CharacterDirection.turnAnimatorParamsSets[num].Apply(this.modelAnimator);
                    }
                }
                this.targetVector   = this.moveVector;
                this.targetVector.y = 0f;
                if (this.targetVector != Vector3.zero && deltaTime != 0f)
                {
                    this.targetVector.Normalize();
                    Quaternion quaternion2 = Util.QuaternionSafeLookRotation(this.targetVector, Vector3.up);
                    float      num2        = Mathf.SmoothDampAngle(this.yaw, quaternion2.eulerAngles.y, ref this.yRotationVelocity, 360f / this.turnSpeed * 0.25f, float.PositiveInfinity, deltaTime);
                    quaternion = Quaternion.Euler(0f, num2, 0f);
                    this.yaw   = num2;
                }
                if (this.targetTransform)
                {
                    this.targetTransform.rotation = quaternion;
                }
            }
        }
Exemplo n.º 3
0
 // Token: 0x060015D3 RID: 5587 RVA: 0x0005CFF0 File Offset: 0x0005B1F0
 private void FixedUpdate()
 {
     this.UpdateAllWheelParameters();
     if (this.inputBank)
     {
         this.moveVector = this.inputBank.moveVector;
         float f = 0f;
         if (this.moveVector.sqrMagnitude > 0f)
         {
             f = Util.AngleSigned(base.transform.forward, this.moveVector, Vector3.up);
         }
         WheelCollider[] array = this.steerWheels;
         for (int i = 0; i < array.Length; i++)
         {
             array[i].steerAngle = Mathf.Min(this.maxSteerAngle, Mathf.Abs(f)) * Mathf.Sign(f);
         }
         array = this.driveWheels;
         for (int i = 0; i < array.Length; i++)
         {
             array[i].motorTorque = this.moveVector.magnitude * this.motorTorque;
         }
     }
 }