Hello, i recently started new project, and have some problems with my car physics. I was searching the internet all day and found this script Code (CSharp): using System.Collections; using System.Collections.Generic; using UnityEngine; public class BMW_i8 : MonoBehaviour { private float m_horizontalInput; // A & D private float m_verticalInput; // W & S private float m_steeringAngle; // Modified by m_horizontalInput public WheelCollider frontDriverW, frontPassengerW; //W = Wheel public WheelCollider rearDriverW, rearPassengerW; public Transform frontDriverT, frontPassengerT; //T = Transform public Transform rearDriverT, rearPassengerT; public float maxSteerAngle = 30; // 30 Degrees Max Steering Angle public float motorForce = 50; // Motor Torque Variable //////////////////////////////////////////////////////////////////////////////////////////////////// public void GetInput() { m_horizontalInput = Input.GetAxis("Horizontal"); //Unity Input Method (Edit > Project Settings > Input) m_verticalInput = Input.GetAxis("Vertical"); } private void Steer() { m_steeringAngle = maxSteerAngle * m_horizontalInput; frontDriverW.steerAngle = m_steeringAngle; frontPassengerW.steerAngle = m_steeringAngle; } private void Accelerate() { frontDriverW.motorTorque = m_verticalInput * motorForce; frontPassengerW.motorTorque = m_verticalInput * motorForce; } private void UpdateWheelPoses() { UpdateWheelPose(frontDriverW, frontDriverT); // Taking Pose Information from _collider and Applying it to the _transform UpdateWheelPose(frontPassengerW, frontPassengerT); UpdateWheelPose(rearDriverW, rearDriverT); UpdateWheelPose(rearPassengerW, rearPassengerT); } private void UpdateWheelPose(WheelCollider _collider, Transform _transform) { Vector3 _pos = _transform.position; Quaternion _quat = _transform.rotation; _collider.GetWorldPose(out _pos, out _quat); // Out Values _transform.position = _pos; _transform.rotation = _quat; } private void FixedUpdate() { GetInput(); Steer(); Accelerate(); UpdateWheelPoses(); } } which i use in my game. Here's video from my problem: I have some stutters while driving, and most important bug is that whatever float i set speed to be, it is approximately always the same, can't go faster. Any tips?
TL;DR: Increase your motorForce value to more than 50. You are moving a Car that weights 1500 kilograms with a force of 100 newtons (50 on each rear wheel). Thats an acceleration of (a = F/m) 0.066 m/s^2, which for what you want is probably very low. Edit: Disregard, as @AlTheSlacker pointed out, I confused Torque and Force...
I see you tried different torque values and it made no difference (incidentally, @Erakk don't confuse torque and force). Have you looked to see how much slip you are getting from the driven wheels? You can get this from GetGroundHit -> WheelHit. I wonder if you are just spinning the wheels. Have you tried to print() m_verticalInput * motorForce from the Accelerate() method to confirm you are reading the controller input correctly? I think the key press routines should be checked in the Update() method not the FixedUpdate() I see you have wheel damping rate set to 1, which I find can be confusing, especially when trying to debug, although I don't think it will be your problem, you could try setting it to 0.0001 (minimum value).