This tutorial is the best of all the tutorials I've watched on this subject. Excellent microphone quality, minimal editing, clear speaking, clear explanations, and very quick!
I used a different car from the asset store, and it accelerated extremely slowly. I had to decrease mass value for the whole car, increase the wheel collider radius (so that it collided with the ground) and increase motor torque to a lot more, and also changed friction values slightly. Just in case anyone faces the same problem. Anyway, great tutorial, it was very clear and easy to follow. I will check your channel for more! Thank you.
If anyone of you have been stuck with the movement, just make sure the car's collider is above the wheel's collider. I don't know if I didn't pay attention but I got stuck on it for 2 days. Thanks for the tutorial. Loved it.
Thank you thank you thank you! I've been struggling through the wheel collider tutorial on Unity's site for two days. The tip you had about adding an additional Box Collider to the root car node (around 9:00) was the trick that fixed my crazy bouncing car!
@@bartwestenenk6088 that doesn't work that good... Just change the wheellcollider sideways slip and forward slip based on the ground physics material. RCC for example does that'
In case your car moves too slowly when accelerating: Try scaling your model (ALL parts of the car + colliders etc) downwards. I somehow assume that the "unity physics system" takes the model size - relative to the world grid size - into consideration when applying physics to it. Somewhere I read, that the grid squares (the smallest one if you zoom in) represent "1 meter". Originally my model was about 8 meters long and accelerated horribly slow. I scaled it from (1,1,1) to (0.2,0.2,0.2) and that did the trick.
Correct, a transform gap of 1 is one meter, and this is linked to the physics notion of a Newton (1kg * meter * meter / second * second). So size does matter when if comes to physics-driven acceleration in Unity.
The car shouldn't look smaller, if you scale all of your other world objects (houses, trees, etc) to the same relative size (like in the real world). Maybe my applied scale (0.2) was too small. I haven't done a lot of experiments with it, but I think you should still be able to have larger cars (8m). Maybe the mass was too big for the adjusted torque of the wheel colliders. Try therefore different values for the mass of the car or wheel collider properties (torque, stiffness, etc) to get the driving behavior you wish. Another thing I learned in UE4 (but can't remember if it is present in Unity) was friction between ground and wheels. This kind of parameter plays an important role for acceleration and steering too.
@@RobertoOrtis Yes, this is exactly going to happen, if you set the fricition too low. Setting the friction too high may get you an unrealistically stable car. But in the end, it all depends on how you want the car to behave in your game.
For those whose car is not moving... I was able to solve this by tweaking the wheel collider's radius (.6 in my case) and changing the motor force (1000 in my case) or resizing the object to a smaller size.
Great Tutorial but I have this issue. I applied Wheel Colliders to my Wheels and everything "technically" works. Problem is that when Play is hit, all 4 wheels flip sideways. Any thoughts as to why that might be or - if not - how I could patch something like that?
U have the cheat code activated that makes the wheels go sideways thus allowing you to run it on water like in GTA! K, jokes aside, I think it's because the car collider is clashing with the wheels collider that's why
It could be indeed your wheels colliding with your car's box collider. A good way to solve this is by setting custom layers for your tires and car, and setting inside the physics tab in project settings so the two layers won't have physical interactions.
@@Cerions33 maybe check the suspension size? in the gizmos they are those orange vertical lines. If they are too big, your wheels will start to tilt when you keep constantly turning.
I think your wheels may not be oriented right, Or try this... Create an empty game object and copy transform from a wheel. After the empty game object is in the position of wheel, you should make wheel object as a child of this empty gameobject. That empty gameobject should be oriented as wheel collider of this wheel and try offsetting the wheel mesh rotation to counter its behaviour in the game mode.
50 motor force is low for 1500 mass. I followed tutorial and put 300 for motor force. Its working perfectly. Thank you so much. Now, I can make a race game against asphalt :)))
Fixed update should be used for physical Calculations and Update for Input/Output. Update is called every frame, FixedUpdate is called 30 or 60 times per second.
regarding FixedUpdate and LateUpdate... Basically before Update is ran there is a before and after update method that you can use for physics (before) and camera (after) respectively most commonly which can fix stutter for the camera when all other object movement is already processed for example... this was mentioned in one of the tutorials
If you want to make aligning anything much easier, use the isometric view by clicking on the small white cube in the middle of the xyz selector found in the upper right of your Scene tab window.
I done everything as Tutorial but car moving very slow when Accelerating+Steering. What can be the reason? I even using same Low Poly Destructible Car. Is unity physics changed in 3 years? Please reply.
I know im late to the party but ive spent a long time and a lot of tutorials deep to get these Wheel colliders working bug free - this is the first tutorial to do that thanks for the Video homie.
As others have pointed out, best tutorial in the subject. I manage to easily adapt a Cinemachine camera to the setup and it's working smoothly. Thanks a lot!
Literally the first useful video I've found on wheel colliders. I do have one issue, everything works fine but the car doesn't move (the wheels turn and rotate, there are no errors) the car just doesn't move :c
this is so long ago but in case other people see, you need to rename the Update() as LateUpdate() or even FixedUpdate() and retry. Should remove the stutter.
I come here because I want to know how carting microgame template in Unity work. And this tutorial is very help full. Your tutorial is very good and straightforward. From now on, will be your subscriber ^_^
If you want to see a real car controller that can challenge to forza just check this ruclips.net/video/oYlMXMozuxg/видео.html video and download playable demo from this link drive.google.com/file/d/1dIe9oqD75A1w7LgpjXRx1ZDMXlvgpZb4/view?usp=sharing On Unity Asset Store: assetstore.unity.com/packages/tools/physics/hd-car-controller-155461 You Tube Channel: ruclips.net/channel/UCivLavXhYn-Ap0IJcNMjmeg?view_as=subscriber HDCarController Version 2 will be on asset store soon. HDProDesign Team
So, when I drop my vehicle, the wheel colliders stop at the ground plane, but the meshes pass through for about three to five frames. It's barely noticeable, but we can't exactly have wheels passing through solid objects, lol. Any ideas? I'm almost tempted to just program my own wheel colliders.
Extremely important...the top parent transform in your vehicle must have a box collider or something similar attached or it will just make your vehicle go crazy bouncing. Struggled for the last 24 hours
hey. Thanks for the video. I have the problem that when I stop the car, it still moves around. Set motor torque to 0 and added a brakeforce. The wheels don't move, but the vehicle is sliding around on the plane. Do you have a soluition for that?
for anyone not sure about the template he is using its not from the store it comes with Unity blogs.unity3d.com/2018/04/26/how-to-get-the-most-out-of-the-new-unity-project-templates-in-2018-1/
Cars don't need brakes right , just kidding. here is code for brakes (brakes = hand brake). but you can apply it to all the w_colliders. [ add this in the Accelerate void or make new one for the brakes called brakes. frontDriverW.brakeTorque = m_brakeInput * brake; frontPassengerW.brakeTorque = m_brakeInput * brake; and make a float like this float public brake = 500; ]
Hi, I wrote a code similar to this but when I run the car start moving backward without any input, I tried several ways but the only thing has changed is the direction of the initial movement, I mean the car starts going forward initial after runic the fame. Does anyone have any idea in this case?
I followed this tutorial and it worked excellent. I then tried to follow this using the golf cart download from the asset store and I can NOT get it to work. It starts spinning and or takes off, or flips over after adjusting the settings. I'm stumped. I was trying to make a golf cart racing game. Any suggestions?
The only issue ive been having is that when i hit play the wheel colliders are bouncing like crazy/stuttering on a flat surface as if they were on an extremely bumpy road. so far I've had no luck figuring out why.
Excellent tutorial for Wheel Colliders. But I have a doubt. In UpdateWheelPose() method where we are actually modifying the wheel mesh transform with the wheel collider transform, i didn't understand the initializing of Vector3 _pos and Quaternion _quat by storing wheel's current position and rotation. Because that function is running without errors with just initializing _pos and _quat, and not storing values into them. They are already getting updated in _collider.GetWorldPose(out _pos, out _quat). If anybody can explain, please!!
I had an issue with the tire geometry clipping through the floor and it took me a little too long to realize the wheel collider's radius should NOT be .08 like mentioned in the video. I used .25 scale, just like you said but the wheel radius was way too small and should actually be 0.34
is the updateWheelPoses() to just update the visuals or to actually drive the car? Will it also drive without that function if I don't want to update any visuals?
hello, when im trying to delete frontdriver reardriver frontpassenger and rearpassenger's materials (cylinder001, rimsize, rimtire) i get "cannot restructure prefab instance" error how can i fix it ?
If you want to see a real car controller that can challenge to forza just check this ruclips.net/video/oYlMXMozuxg/видео.html video and download playable demo from this link drive.google.com/file/d/1dIe9oqD75A1w7LgpjXRx1ZDMXlvgpZb4/view?usp=sharing On Unity Asset Store: assetstore.unity.com/packages/tools/physics/hd-car-controller-155461 You Tube Channel: ruclips.net/channel/UCivLavXhYn-Ap0IJcNMjmeg?view_as=subscriber HDProDesign Team
My car goes flying up real quick at start of runtime. If I slash slash the code out of UpdateWheelPoses, then it goes away, but of course I can't move at that point. Any help??? EDIT: Figured it out. Instead of transform.position = pos, I reversed it to pos = transform.position, as well as for rotation. Worked for me, hope this helps someone else.
If anyone wants to add the ability to control what the vehicle's drive type is, I messed around a bit and basically I just created three bools: public bool fourwheeldrive = false; // 4WD public bool rwd = false; // RWD (Rear Wheel Drive) 2WD Mode. public bool fwd = false; // FWD (Front Wheel Drive) 2WD Mode. Then in the void Accelerate() I replaced the code RC used with this: if (!fourwheeldrive && rwd) { rLWC.motorTorque = m_verticalInput * motorForce; rRWC.motorTorque = m_verticalInput * motorForce; } else if (!fourwheeldrive && fwd) { fLWC.motorTorque = m_verticalInput * motorForce; fRWC.motorTorque = m_verticalInput * motorForce; } else if (fourwheeldrive) { fLWC.motorTorque = m_verticalInput * motorForce; fRWC.motorTorque = m_verticalInput * motorForce; rLWC.motorTorque = m_verticalInput * motorForce; rRWC.motorTorque = m_verticalInput * motorForce; } else { Debug.Log("Drive Type not defined."); } Hope this helps anyone. Note that you will have to replace all of the rLWC, rRWC, etc. with your variables.
I have a problem that I've been working on for two days now...its that my wheels are floating around my vehicle. my wheel colliders are working fine but my wheels are not.
Yes I have...make sure to make the wheels a child of an empty GameObject and The GameObject a child of the Car Body then place the empty game objects in the "wheel" section in the inspector and that should fix it
instead of putting the wheel colliders on the wheels themselves (meaning the game object with the mesh renderer component) create 4 (or how ever many wheels you have) separate empty game objects that will serve as the parent for each wheel. Then put the wheel collider component on those newly created parent game objects and put those parent objects in the wheel collider fields in the inspector view. BTW the parent game objects should be the child of the car body. Hope that helps somebody one day :) @@tommywicaksono
big thanks for the video! Everything works but the handling of the car feels weird (acceleration / breaking). It is as if the car has strong momentum. You can see it if you drive back and forth. Increasing the motor force doesn't help - the inertia / momentum is still working and increasing the force makes it worse.
Hi, I followed the tutorial but my car nevers stops, is like the wheels dont have any friction or lose. Im using the default Wheelcolider values. Great video!
Hey good job, but i''m running into a problem here ... while the left side of mt car is working awesome my right side front and back wheels are turned inside out and the only way to disable that from happening is... private void UpdateWheelPoses() { UpdateWheelPose(frontLW, frontLWT); //UpdateWheelPose(frontRW, frontRWT); UpdateWheelPose(rearLW, rearLWT); //UpdateWheelPose(rearRW, rearRWT); } But then again they look ok but do not spin any suggestions?
how to fix error : error CS1061: Type `UnityEngine.WheelCollider' does not contain a definition for `GetWorldPose' and no extension method `GetWorldPose' of type `UnityEngine.WheelCollider' could be found (are you missing a using directive or an assembly reference?)
Thank you for the tutorial :) for such complex behaviour its actually pretty easy to set up. One thing I noticed is, that you use Time.deltaTime but are updating in FixedUpdate(). Maybe this is the reason your followMovement becomes jittery sometimes. Time.deltaTime relates to Update() / lateUpdate(), whereas Time.fixedDeltaTime relates to FixedUpdate(). I'm actually wondering why there isn't a LateFixedUpdate()... Interesting _codingStyle btw. ^^ Didn't know you can put methods before variables. I haven't made use of the underscore yet. Thinking of adapting that.
If you want to see a real car controller that can challenge to forza just check this ruclips.net/video/oYlMXMozuxg/видео.html video and download playable demo from this link drive.google.com/file/d/1dIe9oqD75A1w7LgpjXRx1ZDMXlvgpZb4/view?usp=sharing On Unity Asset Store: assetstore.unity.com/packages/tools/physics/hd-car-controller-155461 You Tube Channel: ruclips.net/channel/UCivLavXhYn-Ap0IJcNMjmeg?view_as=subscriber HDProDesign Team
The collider doesn't work at all, it goes through on my tire and even when I tried using a cylinder straight from unity itself it still didn't work but capsule collider does for some reason
For some reason my car is slow which I fixed but my car wheels are flying away from my car for god knows why. I know that its because of the transform but I can't seem to make it work.
I've tried to combine this tutorial with my logitech G29. It worked pretty good just one thing when I fully press down my accelerate paddle, my camera jitters. (I've added my camera as a child to the car for now.)
Can anybody tell me if in making turns (in this tutorial script) is involved any friction force or this turns are just made by calculating the position of the wheels and the input from the arrows?
My car is moving and my wheels turn, etc. but I have a problem: all my four wheels turn 180 degrees when I press play. Like the hubcaps turn to the center of the vehicle and the inner rim turns away from the vehicle. I have tried to set them 180 degrees to the other direction but haven't yet found a working solution. Anyone know what I should do?
I had a similar problem where all four of my wheels faced upwards. I suggest you position you wheels in the correct position in the scene, i.e make sure the wheels are facing outwards, then create an empty game object for each wheel (which you can then drag each wheel into to make it a child of it). Make sure that the empty Game object is at the same position as the wheel otherwise the wheel will rotate around the game object's location instead of its own centre. Then, drag each empty game object into the movement script assigned for the collider instead of the wheel itself. This should fix the issue since the script will modify the rotation of the game object in relation to the world (which in turn modifies the rotation of the wheel relative to the game object) instead of the wheel itself, which would change the orientation of the wheel. If that doesn't work you could always try to move the wheel colliders on the left side of the car to the right side and vise versa to see if that helps.
This tutorial is the best of all the tutorials I've watched on this subject. Excellent microphone quality, minimal editing, clear speaking, clear explanations, and very quick!
69 likes Lol
Yes, Finally someone who doesn't type like a grandpa
@@dwinkley HEY NOW MISTER THATS NOT FUNNY SOMETIMES WE DO IT FOR FUN
@@fixyourautomobile ?
@@fixyourautomobile Oh i know
I used a different car from the asset store, and it accelerated extremely slowly. I had to decrease mass value for the whole car, increase the wheel collider radius (so that it collided with the ground) and increase motor torque to a lot more, and also changed friction values slightly. Just in case anyone faces the same problem.
Anyway, great tutorial, it was very clear and easy to follow. I will check your channel for more! Thank you.
thanks a lot *____*
WIWOSEOAW48PS I know it’s late but if you scaled game object with the driving script attached to it you would change the physics I think.
@@lemonface2938 yeah u r correct. It changes the physx. I experienced that bug.
@@lemonface2938 thanks
Bro, I'm not even kidding. Thanks to your comment, I solve a problem that involved hours of research. I forgot to increase the collider radius...
After 3 years your tutorial is still amazing
If anyone of you have been stuck with the movement, just make sure the car's collider is above the wheel's collider. I don't know if I didn't pay attention but I got stuck on it for 2 days. Thanks for the tutorial. Loved it.
it doesn't work for me
@@UniversoDeCosas Is the car not moving?
@@lucidjuice101 now works, thanks
@@UniversoDeCosas Cool, welcome
Thank you thank you thank you! I've been struggling through the wheel collider tutorial on Unity's site for two days. The tip you had about adding an additional Box Collider to the root car node (around 9:00) was the trick that fixed my crazy bouncing car!
Hello, I did the same as mentioned in the tutorial still my car is bouncing. Can you help?
@@AllFather414 same with me . help please
for me, i forgot to increase the mass from one to something higher
Can you do a follow up video for handling different road surfaces. Asphalt vs dirt for example.
I think, you need to add triggers on road, and change wheelcollider friction's settings when you in trigger. That easy
@@sweftis8300 physic materials. ;)
@@sweftis8300 or add different friction for the ground and keep the wheel friction static
@@bartwestenenk6088 that doesn't work that good... Just change the wheellcollider sideways slip and forward slip based on the ground physics material. RCC for example does that'
It helps with my graduation project a lot.Thanks
In case your car moves too slowly when accelerating: Try scaling your model (ALL parts of the car + colliders etc) downwards. I somehow assume that the "unity physics system" takes the model size - relative to the world grid size - into consideration when applying physics to it.
Somewhere I read, that the grid squares (the smallest one if you zoom in) represent "1 meter". Originally my model was about 8 meters long and accelerated horribly slow. I scaled it from (1,1,1) to (0.2,0.2,0.2) and that did the trick.
Correct, a transform gap of 1 is one meter, and this is linked to the physics notion of a Newton (1kg * meter * meter / second * second). So size does matter when if comes to physics-driven acceleration in Unity.
Won't the car look too small compared to other objects? Or is there something I am not getting...?
The car shouldn't look smaller, if you scale all of your other world objects (houses, trees, etc) to the same relative size (like in the real world). Maybe my applied scale (0.2) was too small. I haven't done a lot of experiments with it, but I think you should still be able to have larger cars (8m). Maybe the mass was too big for the adjusted torque of the wheel colliders.
Try therefore different values for the mass of the car or wheel collider properties (torque, stiffness, etc) to get the driving behavior you wish.
Another thing I learned in UE4 (but can't remember if it is present in Unity) was friction between ground and wheels. This kind of parameter plays an important role for acceleration and steering too.
@@seahawk913 thank you, I will look into those. Won't, lowering the friction, make it look like the car is skating on ice?
@@RobertoOrtis Yes, this is exactly going to happen, if you set the fricition too low. Setting the friction too high may get you an unrealistically stable car. But in the end, it all depends on how you want the car to behave in your game.
Helpful af to me multiple times. Mainly the placement of the wheel colliders and the excellent settings to 'tune' them.
this was excellent. video was long, so i was expecting a lot of time wasting, but there really wasn't any. straight to the point and easy to follow.
For those whose car is not moving...
I was able to solve this by tweaking the wheel collider's radius (.6 in my case) and changing the motor force (1000 in my case) or resizing the object to a smaller size.
hell yeah exactly what I needed thank you(:
Great Tutorial but I have this issue.
I applied Wheel Colliders to my Wheels and everything "technically" works. Problem is that when Play is hit, all 4 wheels flip sideways.
Any thoughts as to why that might be or - if not - how I could patch something like that?
U have the cheat code activated that makes the wheels go sideways thus allowing you to run it on water like in GTA!
K, jokes aside, I think it's because the car collider is clashing with the wheels collider that's why
It could be indeed your wheels colliding with your car's box collider. A good way to solve this is by setting custom layers for your tires and car, and setting inside the physics tab in project settings so the two layers won't have physical interactions.
@@albertoneto4781 Have the same problem and I tried resolving your way but it doesn't work..
@@Cerions33 maybe check the suspension size? in the gizmos they are those orange vertical lines. If they are too big, your wheels will start to tilt when you keep constantly turning.
I think your wheels may not be oriented right,
Or try this...
Create an empty game object and copy transform from a wheel. After the empty game object is in the position of wheel, you should make wheel object as a child of this empty gameobject. That empty gameobject should be oriented as wheel collider of this wheel and try offsetting the wheel mesh rotation to counter its behaviour in the game mode.
50 motor force is low for 1500 mass. I followed tutorial and put 300 for motor force.
Its working perfectly. Thank you so much.
Now, I can make a race game against asphalt :)))
If your car doesn't move or move too slow, try to make the car smaller, it worked for me. And thanks for the tutorial
Fixed update should be used for physical Calculations and Update for Input/Output. Update is called every frame, FixedUpdate is called 30 or 60 times per second.
regarding FixedUpdate and LateUpdate... Basically before Update is ran there is a before and after update method that you can use for physics (before) and camera (after) respectively most commonly which can fix stutter for the camera when all other object movement is already processed for example... this was mentioned in one of the tutorials
This is the best tutorial here. Everything in the script is so neatly orchestrated this just works! Much thanks!
That was beautiful. You made a legitimate baby out of that code, and all I have left to say is: Mazel Tov!
best tutorial for wheel colliders, physics working fine
If you want to make aligning anything much easier, use the isometric view by clicking on the small white cube in the middle of the xyz selector found in the upper right of your Scene tab window.
please help me, my wheels are revolving but car isnt moving How to fix this??
i have the same issue my man
@@g3o497 well i got solution, just increase your wheel collider radius to exact 0.34 .it worked for me and make sure you do it in all 4 of them
@@arshigupta9076 Thanks i will try
@@arshigupta9076 Worked for me, thank you!
Hey bro, i got this problem "cannot implicitly convert type unityengine.quaternion' to unityengine.Vector3', how can i solve it?
Me too bro .. did u get ans or any fix?
Look at Quaternion class, it's not the same as Vector3. Read a documentation, it takes 4 arguments (instead of 3).
@@damiankirstein3311 so now what?
28:40
I done everything as Tutorial but car moving very slow when Accelerating+Steering. What can be the reason? I even using same Low Poly Destructible Car. Is unity physics changed in 3 years? Please reply.
When I play it the wheels are rotated 90 degrees and it doesn't work :/ any ideas?
same problem with me did u solve it
Go into the program you used to make the car model and wheels with and rotate the models accordingly
If above dosen't help put the wheel in a empty game object rotate them 90 inside of that object and use that object for placement
seem problem
Great Tutorial, But I have a Problem in Stopping The Car
I Pressed "S" but Car Keeps on rolling
I know im late to the party but ive spent a long time and a lot of tutorials deep to get these Wheel colliders working bug free - this is the first tutorial to do that thanks for the Video homie.
As others have pointed out, best tutorial in the subject. I manage to easily adapt a Cinemachine camera to the setup and it's working smoothly. Thanks a lot!
I got way more out of this than I expected to.
Instant sub, thanks so much!
float angle = max_angle * Input.GetAxis("Horizontal");
front_wheel.steerAngle=angle;
It's work.. but why my car's wheel(mesh wheel) goes crazy when I on the player mode? Help plss
Literally the first useful video I've found on wheel colliders.
I do have one issue, everything works fine but the car doesn't move (the wheels turn and rotate, there are no errors) the car just doesn't move :c
I have the same problem, has anyone figured out why?
Even after few years this tutorial is very useful for me. Great job.
My car is flipping every time i turn left or right.How can i solve the problem?
If I dont make the motorForce= 5000, my car is driving very very slowly. What is the reason of this?
your naming skills are awful xD
but the tutorial is one of the best I've ever seen... good job man
Great tutorial, I especially love the camera code. I was having a lot of jitter following a rigidbody but your code smooths it all out.
this is so long ago but in case other people see, you need to rename the Update() as LateUpdate() or even FixedUpdate() and retry. Should remove the stutter.
I come here because I want to know how carting microgame template in Unity work. And this tutorial is very help full. Your tutorial is very good and straightforward. From now on, will be your subscriber ^_^
If you want to see a real car controller that can challenge to forza just check this ruclips.net/video/oYlMXMozuxg/видео.html video and download playable demo from this link drive.google.com/file/d/1dIe9oqD75A1w7LgpjXRx1ZDMXlvgpZb4/view?usp=sharing
On Unity Asset Store: assetstore.unity.com/packages/tools/physics/hd-car-controller-155461
You Tube Channel: ruclips.net/channel/UCivLavXhYn-Ap0IJcNMjmeg?view_as=subscriber
HDCarController Version 2 will be on asset store soon.
HDProDesign Team
when I press play my car starts breakdancing for some reason, dunno how to fix it
So, when I drop my vehicle, the wheel colliders stop at the ground plane, but the meshes pass through for about three to five frames. It's barely noticeable, but we can't exactly have wheels passing through solid objects, lol. Any ideas? I'm almost tempted to just program my own wheel colliders.
Extremely important...the top parent transform in your vehicle must have a box collider or something similar attached or it will just make your vehicle go crazy bouncing. Struggled for the last 24 hours
Thanks a lot
One of the most useful tutorial so far!
When I put in the script into the car it flies int random directions. The script is all correct.plz help
Same
I corrected it but still I cannot turn
the reason it flies is that the mass is low increase the mass of the rigidbody and it should be working just fine
@@ahmd-salh no wotk,i set at 10k mass,and she fly
Work*,srry for my bad english
would it be smart to use an array for the wheel colliders? This way it's all in one variable? Just curious.
hey. Thanks for the video. I have the problem that when I stop the car, it still moves around. Set motor torque to 0 and added a brakeforce. The wheels don't move, but the vehicle is sliding around on the plane.
Do you have a soluition for that?
for anyone not sure about the template he is using its not from the store it comes with Unity blogs.unity3d.com/2018/04/26/how-to-get-the-most-out-of-the-new-unity-project-templates-in-2018-1/
vre poutana how is the car moving ??? ytou didnt apply any modifications to transform. only to wheel coliders and their graphics
Cars don't need brakes right , just kidding.
here is code for brakes (brakes = hand brake).
but you can apply it to all the w_colliders.
[
add this in the Accelerate void or make new one for the brakes called brakes.
frontDriverW.brakeTorque = m_brakeInput * brake;
frontPassengerW.brakeTorque = m_brakeInput * brake;
and make a float like this float public brake = 500;
]
How can i do that but, with UI buttons?
thank you i have now achieved brakes
good job!
Achievement unlocked: Brake
GetbuttonDown or Get AXis???
my wheel colliders are sideways and it doesent let me rotate them
I have a problem, wheels is spining but car is not stuck and i dont know what to do
Hi, I wrote a code similar to this but when I run the car start moving backward without any input, I tried several ways but the only thing has changed is the direction of the initial movement, I mean the car starts going forward initial after runic the fame. Does anyone have any idea in this case?
Noice,
My car was bouncing around but I forgot to add more weight and it fixed it all
I followed this tutorial and it worked excellent. I then tried to follow this using the golf cart download from the asset store and I can NOT get it to work. It starts spinning and or takes off, or flips over after adjusting the settings. I'm stumped. I was trying to make a golf cart racing game. Any suggestions?
Have you tried increasing the wheel size radius ?
If I watch this video in 2022 ...
How do I download this edition of the video you are using?
The only issue ive been having is that when i hit play the wheel colliders are bouncing like crazy/stuttering on a flat surface as if they were on an extremely bumpy road. so far I've had no luck figuring out why.
Excellent tutorial for Wheel Colliders. But I have a doubt. In UpdateWheelPose() method where we are actually modifying the wheel mesh transform with the wheel collider transform, i didn't understand the initializing of Vector3 _pos and Quaternion _quat by storing wheel's current position and rotation. Because that function is running without errors with just initializing _pos and _quat, and not storing values into them. They are already getting updated in _collider.GetWorldPose(out _pos, out _quat). If anybody can explain, please!!
Watching a movie from 4 years.
Hey i have my car up and ready but the wheels clip through the ground did i miss something? i have wheel colliders
I had an issue with the tire geometry clipping through the floor and it took me a little too long to realize the wheel collider's radius should NOT be .08 like mentioned in the video. I used .25 scale, just like you said but the wheel radius was way too small and should actually be 0.34
the car does not move, half of the tires are in the middle of the floor when the game starts :(, help
Hmm. My wheels spin, but the car does not move for me. This replaced a previous script which did get the car to move!!
is the updateWheelPoses() to just update the visuals or to actually drive the car? Will it also drive without that function if I don't want to update any visuals?
I've tried, but the car doesn't move. What is wrong?
hello, when im trying to delete frontdriver reardriver frontpassenger and rearpassenger's materials (cylinder001, rimsize, rimtire) i get "cannot restructure prefab instance" error how can i fix it ?
Right click on any of the blue highlighted objects in the hierarchy (where it lists everything), and click Unpack Prefab Completely.
If you want to see a real car controller that can challenge to forza just check this ruclips.net/video/oYlMXMozuxg/видео.html video and download playable demo from this link drive.google.com/file/d/1dIe9oqD75A1w7LgpjXRx1ZDMXlvgpZb4/view?usp=sharing
On Unity Asset Store: assetstore.unity.com/packages/tools/physics/hd-car-controller-155461
You Tube Channel: ruclips.net/channel/UCivLavXhYn-Ap0IJcNMjmeg?view_as=subscriber
HDProDesign Team
hi guys, i did everything but when i want to move my front wheels rotate but my car does not move
please help me...
Make sure your box collider does not go bellow your wheel colliders. So lift you box collider above your wheel collider. Give it a go buddy.
Thank you, I fixed it...
And now I try to make a script to break but it doesn’t work.
It’s possible to help me please??
My car goes flying up real quick at start of runtime. If I slash slash the code out of UpdateWheelPoses, then it goes away, but of course I can't move at that point. Any help???
EDIT: Figured it out. Instead of transform.position = pos, I reversed it to pos = transform.position, as well as for rotation. Worked for me, hope this helps someone else.
Sorta works but now I can't move
4:42 how I can Copy that ?
Please help, I tried on a different car and it's going really slow, how do i fix this?
If anyone wants to add the ability to control what the vehicle's drive type is, I messed around a bit and basically I just created three bools:
public bool fourwheeldrive = false; // 4WD
public bool rwd = false; // RWD (Rear Wheel Drive) 2WD Mode.
public bool fwd = false; // FWD (Front Wheel Drive) 2WD Mode.
Then in the void Accelerate() I replaced the code RC used with this:
if (!fourwheeldrive && rwd)
{
rLWC.motorTorque = m_verticalInput * motorForce;
rRWC.motorTorque = m_verticalInput * motorForce;
} else if (!fourwheeldrive && fwd)
{
fLWC.motorTorque = m_verticalInput * motorForce;
fRWC.motorTorque = m_verticalInput * motorForce;
} else if (fourwheeldrive)
{
fLWC.motorTorque = m_verticalInput * motorForce;
fRWC.motorTorque = m_verticalInput * motorForce;
rLWC.motorTorque = m_verticalInput * motorForce;
rRWC.motorTorque = m_verticalInput * motorForce;
} else
{
Debug.Log("Drive Type not defined.");
}
Hope this helps anyone. Note that you will have to replace all of the rLWC, rRWC, etc. with your variables.
I have a problem that I've been working on for two days now...its that my wheels are floating around my vehicle.
my wheel colliders are working fine but my wheels are not.
I have the same problem....have you found any solution yet?
Yes I have...make sure to make the wheels a child of an empty GameObject and The GameObject a child of the Car Body then place the empty game objects in the "wheel" section in the inspector and that should fix it
@@geniusboi2519 can you explain to me? i don't understand
instead of putting the wheel colliders on the wheels themselves (meaning the game object with the mesh renderer component) create 4 (or how ever many wheels you have) separate empty game objects that will serve as the parent for each wheel. Then put the wheel collider component on those newly created parent game objects and put those parent objects in the wheel collider fields in the inspector view. BTW the parent game objects should be the child of the car body. Hope that helps somebody one day :) @@tommywicaksono
Can we stop the car immediately after releasing input?
Sir how to get that script unter things plz sir reply i code correctly ....
I used another car model, and added cylinders instead of wheels. The wheels respond to input, but fall down when i press play
same
big thanks for the video! Everything works but the handling of the car feels weird (acceleration / breaking). It is as if the car has strong momentum. You can see it if you drive back and forth. Increasing the motor force doesn't help - the inertia / momentum is still working and increasing the force makes it worse.
lower the mass of the wheelcolliders
It's not letting me drop the wheel colliders into the collider section
I have a problem. My wheels spin and move left & right but my car does not move at all. Any suggestions ? Thanks !!
You may try reducing your car's mass setting on the rigidbody.
@@RenaissanceCoders thank you so much it works ! :)
@@RenaissanceCoders Weird, I have similar problem with my test box car. Tried to reduce the weight to 1000 but no effect.
I made a custom car mesh and set all the settings as instructed, but the vehicle wont move at all. The tires turn but there is no forward movement
try reducing box collider volume from down
Sidratul Islam thank you broooo
Is there a chance you could make a video with this controller, adding sound and breaking?
@@t_broek I was able to integrate braking, still no clue how to add proper sound to it though. Regardless, thanks for making this series it helped.
@@optigearstudios6161 can you please share your way of adding braking? It would be very helpful. Thank you!
How can i do that but, with UI buttons?
Hi, I followed the tutorial but my car nevers stops, is like the wheels dont have any friction or lose. Im using the default Wheelcolider values. Great video!
Hey good job, but i''m running into a problem here ...
while the left side of mt car is working awesome my right side front and back wheels are turned inside out and the only way to disable that from happening is...
private void UpdateWheelPoses()
{
UpdateWheelPose(frontLW, frontLWT);
//UpdateWheelPose(frontRW, frontRWT);
UpdateWheelPose(rearLW, rearLWT);
//UpdateWheelPose(rearRW, rearRWT);
}
But then again they look ok but do not spin any suggestions?
How can I change the direction the wheels rotate in?
My car behaves weird just like in the start of the video. Please help.
I am using Unity 2018.3.9f1
increase your car's mass
how to fix error : error CS1061: Type `UnityEngine.WheelCollider' does not contain a definition for `GetWorldPose' and no extension method `GetWorldPose' of type `UnityEngine.WheelCollider' could be found (are you missing a using directive or an assembly reference?)
Looks like you missing a using directive or an assembly reference.
I'm getting a Syntax error the way the camera script is currently written, error CS1003. Any ideas? (total newb)
i wanted to ask, how ti implement a brake to it ?
First time seeing your channel. Instant subscribe. Thanks for the great tutorial!
But what about drifting?
can i use this for my game project? and how to use this as mobile inputs like steering wheel and acel&break buttons ?
Thank you for the tutorial :) for such complex behaviour its actually pretty easy to set up.
One thing I noticed is, that you use Time.deltaTime but are updating in FixedUpdate(). Maybe this is the reason your followMovement becomes jittery sometimes. Time.deltaTime relates to Update() / lateUpdate(), whereas Time.fixedDeltaTime relates to FixedUpdate().
I'm actually wondering why there isn't a LateFixedUpdate()...
Interesting _codingStyle btw. ^^ Didn't know you can put methods before variables. I haven't made use of the underscore yet. Thinking of adapting that.
If you want to see a real car controller that can challenge to forza just check this ruclips.net/video/oYlMXMozuxg/видео.html video and download playable demo from this link drive.google.com/file/d/1dIe9oqD75A1w7LgpjXRx1ZDMXlvgpZb4/view?usp=sharing
On Unity Asset Store: assetstore.unity.com/packages/tools/physics/hd-car-controller-155461
You Tube Channel: ruclips.net/channel/UCivLavXhYn-Ap0IJcNMjmeg?view_as=subscriber
HDProDesign Team
Time.deltaTime returns Time.fixedDeltaTime if called within the fixed update loop.
My wheels get stuck to the ground what to do?
The collider doesn't work at all, it goes through on my tire and even when I tried using a cylinder straight from unity itself it still didn't work but capsule collider does for some reason
my wheels are rotated 180 lol how do u fix that?
how to add audio?
For some reason my car is slow which I fixed but my car wheels are flying away from my car for god knows why. I know that its because of the transform but I can't seem to make it work.
I've tried to combine this tutorial with my logitech G29. It worked pretty good just one thing when I fully press down my accelerate paddle, my camera jitters. (I've added my camera as a child to the car for now.)
How did the wheels know how to turn graphically?
sorry but mine dose not collide with the ground(cube)...the only collider that collide is box collider of parent...
Can anybody tell me if in making turns (in this tutorial script) is involved any friction force or this turns are just made by calculating the position of the wheels and the input from the arrows?
Cool video but my wheels fall down when I hit play any solutions for that?
parent the wheels to the car object or car body and they won't fall
My car is moving and my wheels turn, etc. but I have a problem: all my four wheels turn 180 degrees when I press play. Like the hubcaps turn to the center of the vehicle and the inner rim turns away from the vehicle. I have tried to set them 180 degrees to the other direction but haven't yet found a working solution. Anyone know what I should do?
I had a similar problem where all four of my wheels faced upwards.
I suggest you position you wheels in the correct position in the scene, i.e make sure the wheels are facing outwards, then create an empty game object for each wheel (which you can then drag each wheel into to make it a child of it). Make sure that the empty Game object is at the same position as the wheel otherwise the wheel will rotate around the game object's location instead of its own centre. Then, drag each empty game object into the movement script assigned for the collider instead of the wheel itself. This should fix the issue since the script will modify the rotation of the game object in relation to the world (which in turn modifies the rotation of the wheel relative to the game object) instead of the wheel itself, which would change the orientation of the wheel.
If that doesn't work you could always try to move the wheel colliders on the left side of the car to the right side and vise versa to see if that helps.
Who else is here because they’re car is doing what the car at 0:25 is doing?