private void FixedUpdate() { RaycastHit hitOn; RaycastHit hitNear; OnGround = Physics.Raycast(transform.position, Vector3.down, out hitOn, rayMaxDistance); NearGround = Physics.Raycast(transform.position, Vector3.down, out hitNear, rayMaxDistance + 0.8f); VehicleModel.up = Vector3.Lerp(VehicleModel.up, hitNear.normal, Time.deltaTime * 8.0f); VehicleModel.Rotate(0, transform.eulerAngles.y, 0); if (NearGround) { PhysicsSphere.AddForce(transform.forward * speedTarget, ForceMode.Acceleration); PhysicsSphere.AddForce(transform.right * strafeTarget, ForceMode.Acceleration); } else { PhysicsSphere.AddForce(transform.forward * (speedTarget / 10), ForceMode.Acceleration); PhysicsSphere.AddForce(Vector3.down * Gravity, ForceMode.Acceleration); } Vector3 localVelocity = transform.InverseTransformVector(physicsSphere.velocity); localVelocity.x *= 0.9f + (Drift / 10); if (NearGround) { PhysicsSphere.velocity = transform.TransformVector(localVelocity); } if (StopSlopeSlide) { CounterSlopes(hitNear.normal); } }