- Home /
wheel collider input lag problem
hi, im using unity 2020 and I have a problem. I followed a tutorial for a car controller, and have an issue. in link below there is a video, and when I put motorForce from a 1000 to 2000 or 3000, and try to break, it will wait a few seconds before breaking, I think it is the problem with wheel colliders itself, not with the script, does someone know how to fix this?
sorry if it is a begginer question or a stupid one, but I just started learning unity and c# so im not the sharpest tool in the shed for this one hehe.
edit: here is the code: using System.Collections; using System.Collections.Generic; using UnityEngine; public class carController : MonoBehaviour { private float horizontal; private float vertical; private float currentSteerAngle; private float currentBreakForce; private bool isBreaking; private bool isInInterior; [SerializeField] private float motorForce; [SerializeField] private float breakForce; [SerializeField] private float maxSteerAngle; [SerializeField] private WheelCollider frontLeftWheelCollider; [SerializeField] private WheelCollider frontRightWheelCollider; [SerializeField] private WheelCollider rearLeftWheelCollider; [SerializeField] private WheelCollider rearRightWheelCollider; [SerializeField] private Transform frontLeftWheelTransform; [SerializeField] private Transform frontRightWheelTransform; [SerializeField] private Transform rearLeftWheelTransform; [SerializeField] private Transform rearRightWheelTransform; [SerializeField] private Camera camInside; [SerializeField] private Camera camOutside; // Update is called once per frame void Update() { getInput(); HandleMotor(); handleSteering(); UpdateWheels(); } void HandleMotor() { rearLeftWheelCollider.motorTorque = vertical * motorForce * 1.5f; rearRightWheelCollider.motorTorque = vertical * motorForce * 1.5f; currentBreakForce = isBreaking ? breakForce : 0f; applyBreakingForce(); } void applyBreakingForce () { frontRightWheelCollider.brakeTorque = currentBreakForce; frontLeftWheelCollider.brakeTorque = currentBreakForce; rearRightWheelCollider.brakeTorque = currentBreakForce; rearLeftWheelCollider.brakeTorque = currentBreakForce; } void handleSteering () { currentSteerAngle = maxSteerAngle * horizontal; frontLeftWheelCollider.steerAngle = currentSteerAngle; frontRightWheelCollider.steerAngle = currentSteerAngle; } void getInput() { horizontal = Input.GetAxis("Horizontal"); vertical = Input.GetAxis("Vertical"); isBreaking = Input.GetKey(KeyCode.Space); } void UpdateWheels () { updateSingleWheel(frontLeftWheelCollider, frontLeftWheelTransform); updateSingleWheel(frontRightWheelCollider, frontRightWheelTransform); updateSingleWheel(rearLeftWheelCollider, rearLeftWheelTransform); updateSingleWheel(rearRightWheelCollider, rearRightWheelTransform); } void updateSingleWheel (WheelCollider wheelCollider, Transform wheelTransform) { Vector3 pos; Quaternion rot; wheelCollider.GetWorldPose(out pos, out rot); wheelTransform.rotation = rot; wheelTransform.position = pos; } }
edit: this is the tutorial: https://www.youtube.com/watch?v=Z4HA8zJhGEk&t
Answer by ElmisteriosoYtz · May 09, 2021 at 03:02 AM
You know sometimes I have problems with the colliders too, although I have been in this for a while, one sometimes makes mistakes that should not be made, I say try modifying the colliders or if you do not pass the code, I will check it and tell you if they would be the colliders or the script, remember "the truth is out there"
Your answer

Follow this Question
Related Questions
car accelerates too slow ? 0 Answers
Does anyone know good free wheel collider alterantives? 0 Answers
How to properly use WheelCollider GetWorldPos 0 Answers
Strange Wheel Colliders 0 Answers
Problems with cars in Unity 5 0 Answers