Simple Car Controller in Unity Tutorial

  Рет қаралды 327,797

GameDevChef

GameDevChef

Күн бұрын

Пікірлер: 694
@T0MM0-Lds
@T0MM0-Lds 2 жыл бұрын
As much as all the information is there and it's fantastic to use. Please remember this is a tutorial; not a speed run.
@hawkgamedev
@hawkgamedev 2 жыл бұрын
there is also "Playback Speed" and "pause the video" you know ...
@T0MM0-Lds
@T0MM0-Lds 2 жыл бұрын
@@hawkgamedev wow thanks! Never knew that was there! ❤️ Pillock
@hawkgamedev
@hawkgamedev 2 жыл бұрын
@@T0MM0-Lds you are welcome poor fish.
@himanshuVisuals
@himanshuVisuals 2 жыл бұрын
my car dont turn left and right
@hawkgamedev
@hawkgamedev 2 жыл бұрын
@@himanshuVisuals hey man share in your discord I'll help you.
@Massive-3D
@Massive-3D 3 жыл бұрын
I was so afraid to scroll down and see "video upload date: 5 years ago" Subscribed!
@uniquelyrics2331
@uniquelyrics2331 3 жыл бұрын
lol
@matheusmartins3177
@matheusmartins3177 3 жыл бұрын
me too LOL
@monkeyrobotsinc.9875
@monkeyrobotsinc.9875 3 жыл бұрын
i HATE that.
@SajeehSamad
@SajeehSamad 3 жыл бұрын
lol
@RandomNovaGames
@RandomNovaGames 4 жыл бұрын
Maybe the first video that I have seen that teaches you to create a nice car handling for free. Good place for me to start. Others dont handle well at high speeds
@3bomb
@3bomb 2 жыл бұрын
Just a quick heads up, this script is using negative motor torque to handle braking when pressing "S." Per Unity's documentation, negative motor torque should not be used for braking. If you'd like to apply brakeTorque instead of negative motorTorque, create an if statement that says if verticalInput < 0 then brakeTorque = -verticalInput * brakeForce.
@vilmerforsberg
@vilmerforsberg Жыл бұрын
in which part of the scrpit should you put this? btw i really liked your car video:)
@luiss.2005
@luiss.2005 3 жыл бұрын
I really like this tutorial because you show some common mistakes and how to avoid them. For example: setting the box collider incorrectly or using Lerp insead of SmoothDamp. Unity is not a black box where you input the correct values and everything works just fine. Making games (or anything, really) is iterative. I think showing the process can be very encouraging for beginners.
@joooosl
@joooosl 3 жыл бұрын
What did you use in HandleRotation? There is no SmoothDamp
@luiss.3866
@luiss.3866 Жыл бұрын
Are we brothers?
@carolineyonatan216
@carolineyonatan216 4 жыл бұрын
Lol i see this ad while watching dani
@swastikmishra8822
@swastikmishra8822 4 жыл бұрын
Same bro
@vvixell1
@vvixell1 4 жыл бұрын
same
@neongreggyyt1115
@neongreggyyt1115 4 жыл бұрын
Same
@suanzalal
@suanzalal 4 жыл бұрын
Ah. I see you're a Boner aswell.
@youdaily7113
@youdaily7113 4 жыл бұрын
Ssssssnanananana same
@rubenopenworld8405
@rubenopenworld8405 4 жыл бұрын
I mean yes you are doing things and i guess it works for experienced users of unity but you should explain more why you would do certain steps, idk when i would try this for some other thing i would not remember how to do it
@nahiyanalamgir7056
@nahiyanalamgir7056 3 жыл бұрын
Agreed. I think the main problem is that these tutorial producers write code continuously without running the game to show the results at every step. Instead they probably just write the entire code at once before making the videos and copy every line from there, explaining each line lightly.
@monkeyrobotsinc.9875
@monkeyrobotsinc.9875 3 жыл бұрын
im somewhat experienced and i still had to pause the video every 2 and a half seconds to catch up with the typing. hes crazy.
@dradex9562
@dradex9562 3 жыл бұрын
@@monkeyrobotsinc.9875 you know he sped up that part right????
@samochreno
@samochreno 3 жыл бұрын
@@monkeyrobotsinc.9875 you have to be kidding, if youre somewhat experienced you should be able to catch up with this easily
@axer1015
@axer1015 3 жыл бұрын
Man only problem is YOU GO TOO FAST! GO SLOWER!
@1agent3LT
@1agent3LT 3 жыл бұрын
yea
@jorande1e
@jorande1e 2 жыл бұрын
The pause button exists
@WajiD_xD
@WajiD_xD 2 жыл бұрын
Or just leave the world
@Rodehaas
@Rodehaas 2 жыл бұрын
0.5x speed?
@counterpointerz-rocketleag2038
@counterpointerz-rocketleag2038 3 жыл бұрын
thanks, you guys will definitely need to do some research about the different things he did, but coding is all about teaching yourself
@bopark1783
@bopark1783 Жыл бұрын
This is really awesome video for newbie! Everyone in the youtube just skips parts of how to setting up the objects and not fully explain how each code works. But this video is really kind to explain how to take each steps!!
@markpolak8622
@markpolak8622 4 жыл бұрын
You are missing the brakek force reset, the if(isBraking) {applybreak()} is wrong because, the 0f breakforce never applies, it means once you braked the car just stops and cant go anywhere, you shoul always apply the bake
@jacobpatron8387
@jacobpatron8387 3 жыл бұрын
@PRANAY G.V. Inside the HandleMotor() function you could add this code to fix that bug, you may have already figured out a solution but hopefully it can at least help someone else. Basically, this code checks if isBreaking is false, if it is it sets the brakeTorque for each wheel to 0. if (!isBreaking) { frontRightWheelCollider.brakeTorque = frontLeftWheelCollider.brakeTorque = backRightWheelCollider.brakeTorque = backLeftWheelCollider.brakeTorque = 0f; }
@MrLiam111
@MrLiam111 3 жыл бұрын
@PRANAY G.V. Just remove the IF from the ApplyBreaking method
@rahulprasad8906
@rahulprasad8906 3 жыл бұрын
@@jacobpatron8387 thank you!
@tejaskale6823
@tejaskale6823 3 жыл бұрын
@@jacobpatron8387 thankyou soooo much dude
@bamers404
@bamers404 3 жыл бұрын
@@jacobpatron8387 thanks 🙏
@joshuastoddard3556
@joshuastoddard3556 Жыл бұрын
Super Helpful!!! By the way if you make the engine to powerful it the car will flip. I made a little script to fix that though. Script: using System.Collections; using System.Collections.Generic; using UnityEngine; public class Flip : MonoBehaviour { void Update() { if (Input.GetKeyDown(KeyCode.V)) { transform.rotation = Quaternion.Euler(0, 0, 0); } } }
@lawrenceredmacher4382
@lawrenceredmacher4382 2 жыл бұрын
I've found that changing suspension spring target position to 1 makes the car basically unable to flip over. or change it to 0 to make it super easy to flip :D
@nikkuzmich5378
@nikkuzmich5378 3 жыл бұрын
Great tutorial! I did the same with my car, but I had one strange problem: my wheels do not rotate around themselves, they rotate in a circle with a certain radius... I solved this by creating empty objects in the same place as wheels, and used them as transforms. But I think this is not an ideal solution, as in a collision the wheels are raised... and not lowered.
@hdprodesignteam231
@hdprodesignteam231 2 жыл бұрын
Hi Niaz. Check this links: Hope helps. kzbin.info/www/bejne/fIfZXpt7l6mEd8U kzbin.info/www/bejne/fZ3EoJyQbZV-mbc Playable Demo : drive.google.com/file/d/1_JnQSfTP8E7EfKZhJVdClohhxBQ7cgei/view?usp=sharing Kindly waiting for your comments to improve it. Thanks.
@forgodsakejake
@forgodsakejake 2 жыл бұрын
i had the exact same issue, was trying to find a solution for so long so thank you for this
@vincenthornak7469
@vincenthornak7469 2 жыл бұрын
@@forgodsakejake I am still confused on how they got this working... I am having the exact same issue. Any tips?
@gglobensky
@gglobensky 2 жыл бұрын
It's because the pivot point of the object is not in the center. Just parent the mesh onto a gameObject with the right pivot and move all the scripts to the empty parent you just created.
@bowl1858
@bowl1858 2 жыл бұрын
Good tutorial, one question. When I start moving my car, once it gets to a certain speed it starts jittering side to side really quickly and leans to the left. My wheels are all at the same y axis, and tinkering with the settings is doing nothing. How do i fix this????
@Rikko230392
@Rikko230392 2 жыл бұрын
I have same problem
@Jimblesnitronbo
@Jimblesnitronbo 2 жыл бұрын
I had the same problem too, but whenever I change the mass in the car's "Rigidbody" component, it fixes it! Hope this helps!
@tonyhamilton7785
@tonyhamilton7785 3 жыл бұрын
This is hella advanced. All I need is to make the car turn left & right when moving
@saiyanpridezbudokitenkaich3444
@saiyanpridezbudokitenkaich3444 3 жыл бұрын
Its not advanced if u understand c# but this guy speaks faster than 6000 MotorTorque
@BerzahMusic
@BerzahMusic 3 жыл бұрын
lol
@bamers404
@bamers404 3 жыл бұрын
Then a car game is not for you. Because it's all bout physics
@tonyhamilton7785
@tonyhamilton7785 3 жыл бұрын
@@bamers404 Not really. I learned a lot over these months. Even the best programmers have to google how-to and error videos. Its all about following instructions to know how to do it in the future. I made a car game and got it working, but I scratched it for other ideas
@FelineRaptor-gv4te
@FelineRaptor-gv4te 3 жыл бұрын
If you want it so simple without proper physics, then try this- using System.Collections; using System.Collections.Generic; using UnityEngine; public class MyCarController : MonoBehaviour { public float maxSpeed = 30f; // Our maximum speed allowed. public float curSpeed; // Current Speed; public float applySpeed = 20f; // How much force to apply (Forward). public float brakeForce = -10f; // Breaks. public Rigidbody myRigid; // Our Rigidbody. public int turnAmount; void Start() { myRigid = GetComponent(); // Gets the players Rigidbody. } void FixedUpdate() { curSpeed = myRigid.velocity.z; if(curSpeed >= maxSpeed) { applySpeed = curSpeed; } if(Input.GetKey(KeyCode.UpArrow)) { //Apply Accelleration myRigid.AddRelativeForce(Vector3.forward * applySpeed); } if(Input.GetKey(KeyCode.DownArrow)) { //Apply BREAKS myRigid.AddRelativeForce(Vector3.back * brakeForce); } } void Update() { if(Input.GetKey(KeyCode.A)) { transform.Rotate(Vector3.up * -turnAmount * Time.deltaTime); } if(Input.GetKey(KeyCode.D)) { transform.Rotate(Vector3.up * turnAmount * Time.deltaTime); } } This wasactually a script for flying a plane in a post in Unity Answers but I tweaked the script to make it a car controller. Just remember to add a rigidbody [with mass 1] to your car GameObject and a box collider with a suitable size and position. Any problem wiht the script, ask me.
@TheEdugato100
@TheEdugato100 3 жыл бұрын
im a simple beginner, i just want my cube to move...
@froosx9418
@froosx9418 3 жыл бұрын
well that's pretty easy i can actually send u the script if you'd like
@isaiahcancode2649
@isaiahcancode2649 3 жыл бұрын
@@froosx9418 please show me
@isaiahcancode2649
@isaiahcancode2649 3 жыл бұрын
nvm i already know how to
@DARK_AMBIGUOUS
@DARK_AMBIGUOUS 3 жыл бұрын
Use bolt and then open the flow graph and make ad a thing called “on keyboard input” and then add a “position translate” thing and then make it so everyone you press W it moves the cube 1 on the x axis, and do the same thing with S but make it move -0.5 or -1 and then add a rotation translation thing and make it so it rotates 1 on the Z axis when you press A
@gamer-revolution
@gamer-revolution 3 жыл бұрын
ok i am just like dani i only copy tutorials and not learn
@monkeyrobotsinc.9875
@monkeyrobotsinc.9875 3 жыл бұрын
really cool that this worked, thanks, but i just used cinemachine for the follow camera.
@FelineRaptor-gv4te
@FelineRaptor-gv4te 3 жыл бұрын
yeah, it would be more flexible actually because you can customize the value and get any behaviour you want. Also the cam look script in the video is not very comfortable while steering [same with standard assets cam look].
@DrSwagGaming
@DrSwagGaming 2 жыл бұрын
@Hawk Game Dev Hey sorry for asking but I am having a problem... When I am clicking the play button. The left side of my car sinks in the ground while other stays normal (like a flat tire for left side). How can i fix? If u know ofcourse
@ElectronGOD
@ElectronGOD 4 жыл бұрын
Once the BrakeTorque is applied, car does not move again when I release the break. Plz help.
@GameDevChef
@GameDevChef 4 жыл бұрын
You can try to remove the isBreaking check on line 45 and make sure that the brakeTorque is set to 0 when spacebar is not pressed.
@boinas
@boinas 4 жыл бұрын
you can try to do this: private void HandleMotor() { if (isBreaking) breakForce = 3000; else breakForce = 0; frontLeftWheelCollider.motorTorque = verticalInput * motorForce; frontRightWheelCollider.motorTorque = verticalInput * motorForce; currentBreakForce = isBreaking ? breakForce : 0f; // you don't need this part because of the if and else you do upper ApplyBreaking(); } ApplyBreaking () { // right there i don't put all wheel colliders! the type of wheel colliders you put here is according to the traction you want to put in the car! // I put for a RWD car (rear-wheel drive)! the video is made for AWD car (all-wheels drive)! // It's to everyone's taste! ;D rearLeftWheelCollider.brakeTorque = currentBreakForce; rearRightWheelCollider.brakeTorque = currentBreakForce; } This method works but if you want a clean and more professional code try to do the wheels colliders with lists! and you can call the wheels with a simple foreach! And carefull because "break" writes "brake"! it's normal this type of errors while programming! especially if you're not english! i can't talk about this because even I do this type of errors! but if you want a correct code try to change "break" and "breaking" to "brake" and "braking"! But sure it was a good tutorial! Congratulations GameDevChef! Keep like that! One more like! 👍 =D
@GameDevChef
@GameDevChef 4 жыл бұрын
I found the problem. Remove the isBreaking check on line 52 in Car Controler script. That should make it work
@shivamchhapola5245
@shivamchhapola5245 4 жыл бұрын
@@GameDevChef can you explain why it works without the check
@theplaymakerno1
@theplaymakerno1 3 жыл бұрын
Got please you mate. This script is better than most of the bloated crap we find on the asset store.
@halivudestevez2
@halivudestevez2 2 жыл бұрын
Seems to be perfect, must try it. (I am lazy, so I will write a code that recognizes wheel colliders, and assign them to an array)
@IGNACY-fp8zo
@IGNACY-fp8zo 2 жыл бұрын
The wheels just instantly fly off and sink below the ground for me and for some reason the breaks seem to accelerate the flying wheels
@kavipriyank8298
@kavipriyank8298 2 жыл бұрын
Totally the same here! For me, the wheels seem to detach from the car's body in a weird manner and fly away. Its transform keeps changing constantly, while the car's body just falls down on land.
@blissweb
@blissweb 3 жыл бұрын
I came here to see how to fix the purple car syndrome and you did that in the first minute. :-) Yay.
@clement2814
@clement2814 Жыл бұрын
Thank you so much. It's fast and efficient as needed.
@walney2008
@walney2008 3 жыл бұрын
very good, I'm a beginner, I'm from Brazil, I learned to put the car in motion, thank you very much, would there be a video teaching you how to create a race track for you, have a lap counting system and checkpoints?
@MphasieMusic
@MphasieMusic 3 жыл бұрын
OMG THANK YOU! You saved my project
@FC12CGaming
@FC12CGaming 3 жыл бұрын
Omg thanks so much, i'm literally speechless that it actually works!!!!
@idkidc1885
@idkidc1885 3 жыл бұрын
Hey man did u try it out on the new version of unity ?if yes does it work on the new version or only one the one he is using
@FC12CGaming
@FC12CGaming 3 жыл бұрын
@@idkidc1885 no im using 2019.4
@FC12CGaming
@FC12CGaming 3 жыл бұрын
@@idkidc1885 but it should work on the new unity
@idkidc1885
@idkidc1885 3 жыл бұрын
@@FC12CGaming ok ty if it doesnot work on the new ill try that version
@FC12CGaming
@FC12CGaming 3 жыл бұрын
@@idkidc1885 k
@SakthivelNadar
@SakthivelNadar 3 жыл бұрын
This is sooo simple it reminds me physics and maths class not that much i ever attended to maths
@ZyronJeff_0915
@ZyronJeff_0915 2 жыл бұрын
Thank you for tNice tutorials. You've done a great job breaking down the features and build. I can now concentrate on my instead of the
@operationreddit1804
@operationreddit1804 3 жыл бұрын
great tutorial, exactly what I was looking for, there is only one problem that i'm facing. its input lag. when I put motorForce to 2000 for example, and when I try to break, there is a lag of about second or 2 before starting to break, and problem is amplified with higher numbers, at 5000 its about 4-5 seconds. does someone have a solution for this?
@hdprodesignteam231
@hdprodesignteam231 2 жыл бұрын
Check this links: Hope helps. kzbin.info/www/bejne/fIfZXpt7l6mEd8U kzbin.info/www/bejne/fZ3EoJyQbZV-mbc Playable Demo : drive.google.com/file/d/1_JnQSfTP8E7EfKZhJVdClohhxBQ7cgei/view?usp=sharing Kindly waiting for your comments to improve it. Thanks.
@lostsoop
@lostsoop 3 жыл бұрын
How can i change the speed / acceleration of the car?
@matymare
@matymare 3 жыл бұрын
Change motor force amount
@lostsoop
@lostsoop 3 жыл бұрын
@@matymare it doesnt help ig but thank you anyways
@barebones.
@barebones. 3 жыл бұрын
if you want to make it slower then you can increase drag ( 1 - 3 will probably be as high as you can go ), but im not sure how to make it faster.
@lostsoop
@lostsoop 3 жыл бұрын
@@barebones. i think the car falls over when i increase the drag
@Max-kb6ui
@Max-kb6ui 3 жыл бұрын
@@lostsoop Same problem
4 жыл бұрын
Thank you for making it simple
@elitebooger8208
@elitebooger8208 4 жыл бұрын
So my car just flys threw the air and I changed the weight on the wheels and body.
@musicland5786
@musicland5786 4 жыл бұрын
Just add a component (rigid body)
@diliupg
@diliupg 3 жыл бұрын
congratulations on the flying car! :-D
@0kr4m
@0kr4m 2 жыл бұрын
great tutorial! one question: is there a way to give a boost in speed? I can't even change speed values.
@bloggerblogger2410
@bloggerblogger2410 2 жыл бұрын
yea i've the same question i need the car to accelerate quicker and go faster and changing the speed/motorForce didn't help at all .
@gamedev_navneet
@gamedev_navneet 3 жыл бұрын
I like your discipline while coding.
@mythicaldriftz3357
@mythicaldriftz3357 3 жыл бұрын
Are you some sort of wizard man i have so much respect for you dude i have tried this and it works yes so to anyone wanna try just do it as he says
@RavishingPimp
@RavishingPimp Жыл бұрын
(If anyone needs it. I did make some differences (Like capital letters on some stuff, but that's all) using System.Collections; using System.Collections.Generic; using UnityEngine; public class CarController : MonoBehaviour { // Rename the terms used in the Unity physics engine private const string HORIZONTAL = "Horizontal"; private const string VERTICAL= "Vertical"; private float HorizonalInput; private float VerticalInput; private float currentbreakForce; private float steerAngle; // Choose whether to break or not private bool IsBreaking; [SerializeField] private float motorForce; [SerializeField] private float breakForce; [SerializeField] private float maxSteerAngle; // SerializeField is because we don't want other scripts to access it, but we do in the inspector [SerializeField] private WheelCollider FrontLeftWheelCollider; [SerializeField] private WheelCollider FrontRightWheelCollider; [SerializeField] private WheelCollider RearLeftWheelCollider; [SerializeField] private WheelCollider RearRightWheelCollider; [SerializeField] private Transform RearRightWheelTransform; [SerializeField] private Transform RearLeftWheelTransform; [SerializeField] private Transform FrontRightWheelTransform; [SerializeField] private Transform FrontLeftWheelTransform; // We use "FixedUpdate" because we need to use the Unity physics engine private void FixedUpdate() { GetInput(); HandleMotor(); HandleSteering(); UpdateWheel(); } private void GetInput() { HorizonalInput = Input.GetAxis(HORIZONTAL); VerticalInput = Input.GetAxis(VERTICAL); IsBreaking = Input.GetKey(KeyCode.Space); } private void HandleMotor() { FrontLeftWheelCollider.motorTorque = VerticalInput * motorForce; FrontRightWheelCollider.motorTorque = VerticalInput * motorForce; currentbreakForce = IsBreaking ? breakForce : 0f; if (IsBreaking) { ApplyBreaking(); } } private void ApplyBreaking() { FrontRightWheelCollider.brakeTorque = currentbreakForce; FrontLeftWheelCollider.brakeTorque = currentbreakForce; RearRightWheelCollider.brakeTorque = currentbreakForce; RearLeftWheelCollider.brakeTorque = currentbreakForce; } private void HandleSteering() { steerAngle = maxSteerAngle * HorizonalInput; FrontLeftWheelCollider.steerAngle = steerAngle; FrontRightWheelCollider.steerAngle = steerAngle; } private void UpdateWheel() { UpdateSingleWheel(FrontLeftWheelCollider, FrontLeftWheelTransform); UpdateSingleWheel(FrontRightWheelCollider, FrontRightWheelTransform); UpdateSingleWheel(RearRightWheelCollider, RearRightWheelTransform); UpdateSingleWheel(RearLeftWheelCollider, RearLeftWheelTransform); } private void UpdateSingleWheel(WheelCollider WheelCollider, Transform wheelTransform) { Vector3 pos; Quaternion rot; WheelCollider.GetWorldPose(out pos, out rot); wheelTransform.rotation = rot; wheelTransform.position = pos; } }
@erfanroghani
@erfanroghani 2 жыл бұрын
Excellent tutorial, man! Super useful. But for my application, I need to ensure there is no rotation around the X-axis while applying the brake. How should I set the parameters?
@ghostawader9228
@ghostawader9228 2 жыл бұрын
Sorry I'm totally new to programming but why doesnt the Input.GetAxis and the Input.GetKey(Keycode.....) change color when I write it down on C# the exact same way he did it at 4:01. I noticed it happens to more rows aswell
@ghostawader9228
@ghostawader9228 2 жыл бұрын
It even gives me a warning about it at the bottom in a red text
@Nexus-fi1hb
@Nexus-fi1hb 4 жыл бұрын
The wheel colliders of my car just detatch and fly into the air and pressing wasd doesen't change anything, pls help
@m0ch1_6
@m0ch1_6 4 жыл бұрын
Hey Nexus, to fix your problem you should ensure that wheel collider and wheel mesh are not on the same game object or child
@Nexus-fi1hb
@Nexus-fi1hb 4 жыл бұрын
@@m0ch1_6 thx, I've already fixed that problem, but now I can't get my car to get faster, no matter what motor force I set. It just keeps driving at the same speed.
@AugGust
@AugGust 4 жыл бұрын
@@Nexus-fi1hb U mean for acceleration? If turn the camera to the side u can see in the sample project, the tyres do not have enough grip and the tyres just slip
@lukascampbell5881
@lukascampbell5881 3 жыл бұрын
@@AugGust hey, do you know what i should do if only my front two wheels are rotating? (& turning)
@AugGust
@AugGust 3 жыл бұрын
@@lukascampbell5881 The setup for the front and back wheels should be identical? Just go through and make sure you didn't miss anything
@anonymousa7030
@anonymousa7030 3 жыл бұрын
THANK YOUU!! it is very simple and helpful
@theabbie3249
@theabbie3249 2 жыл бұрын
is the updateWheel() for updating the visuals or actually driving the car? can I get away without using it?
@bithigh8301
@bithigh8301 Жыл бұрын
It works pretty good. Thank you!
@thelife8836
@thelife8836 4 жыл бұрын
The best tutorial. Is single wheel update method essential?
@dwinkley
@dwinkley 3 жыл бұрын
He stole the code from kzbin.info/www/bejne/oGfChICajMp6fKs
@timhoutman6413
@timhoutman6413 3 жыл бұрын
5:35 love the way how you say motor torques. Thanks for the video man.
@victorfiy9844
@victorfiy9844 2 жыл бұрын
dude everything is nice and all but how do i add lerp to the Turing of wheel from left to right because it just snaps which i don't like so any idea on how to
@Twiney_
@Twiney_ 2 жыл бұрын
This is my first time coding and it works great thanks dude!
@infinit_y7000
@infinit_y7000 Жыл бұрын
The script wouldn't work it tell me "the reference script on this Behaviour (Game Object 'Car' ) is missing"
@TheCoolcomplex
@TheCoolcomplex 2 жыл бұрын
why are the rear wheels being updated if the parameters of rear wheel colliders never change? from my understanding, the front wheel colliders move according to the torque that is being applied, and the wheel transforms have to be updated to match the wheel collider positions and rotations, but from the code itself, the rear wheel colliders do not move since the torque is only applied to the front wheels in the code, so how do the rearwheel colliders move?
@miguelpereira4645
@miguelpereira4645 2 жыл бұрын
The physics system automatically move them when the car moves because they are rolling in the ground
@eleanordare9350
@eleanordare9350 2 жыл бұрын
very clear and solved all my problems, thanks so much :-)
@gamedev_navneet
@gamedev_navneet 3 жыл бұрын
Thank-you , this is working perfectly!👍
@roostydoo2
@roostydoo2 3 жыл бұрын
Will it still work if you don't use lwrp project ?? EDIT: I'm using 3d with extras
@punit11super
@punit11super 3 жыл бұрын
Yes it will
@boomboyag4614
@boomboyag4614 3 жыл бұрын
I don’t think anything in the scripts deals with rendering.
@Theferrariguy
@Theferrariguy 4 жыл бұрын
Whenever I play the game, The car's motor and brake force change to different setting sand the car goes really slowly please help
@harshvardhanmisal2255
@harshvardhanmisal2255 4 жыл бұрын
Change it in inspector window click on object which has script and then change the values
@Croccolucho
@Croccolucho 3 жыл бұрын
Got the same problem, idk what to do
@Theferrariguy
@Theferrariguy 3 жыл бұрын
@@Croccolucho I ended up using vehicle physics pro asset it's very useful I'd recommend it
@Vetrillum
@Vetrillum 2 жыл бұрын
Thanks, it worked! But the rear wheels are rotated at Y180, please help
@farruholimov8281
@farruholimov8281 2 жыл бұрын
WheelCollider's GetWorldPose is messing up WheelTransform's position. It's pushing the wheel away for certain distance. What might cause it?
@wingy4387
@wingy4387 3 жыл бұрын
Followed exactly as you did, but sadly my car still seems to spin out so easily when turning, I've played with changing values and have also moved the wheel colliders slightly, which helped a bit but it still can't handle driving around a track at speed, what can I do to make it better?
@hdprodesignteam231
@hdprodesignteam231 3 жыл бұрын
Hey Wingy, Here some links for the HD Car Controller V 3.5. kzbin.info/www/bejne/fIfZXpt7l6mEd8U kzbin.info/www/bejne/fZ3EoJyQbZV-mbc Playable Demo : drive.google.com/file/d/1_JnQSfTP8E7EfKZhJVdClohhxBQ7cgei/view?usp=sharing Kindly waiting for your comments to improve it. Thanks. Best Regards HD Pro Design Team
@simplygamedeveloper7859
@simplygamedeveloper7859 2 жыл бұрын
Change the value of suspension to 1.
@TFG287
@TFG287 3 жыл бұрын
Assets\sCRIPTS\CarControol.cs(72,1): error CS1022: Type or namespace definition, or end-of-file expected :I need help
@muhdasyraf9928
@muhdasyraf9928 2 жыл бұрын
Hi! I got a problem when using your code... it seems that my car dint stop accelerate after i press forward...any idea to fix it??
@RobertGatesC
@RobertGatesC 4 жыл бұрын
Dude, you are a lifesaver. Thank you, brother. I was looking for a vid that would go step by step through the process, and if people want to check the coding under the hood so to speak, you have that too. For someone that doesn't know coding, and wants to put out a game, this is amazing info. And how you did it step by step. Love it. Would you also be able to make a vid of how to easily train any AI car to run a track, and with other AI cars? If so, that would be amazing. Thanks again, and a big thumbs up from me. :)
@FelineRaptor-gv4te
@FelineRaptor-gv4te 3 жыл бұрын
As for ai cars, you can check out Unity's standard assets. there is something called car ai waypoint.
@wa-ir1br
@wa-ir1br 4 жыл бұрын
広告から飛んできたけどまじでわかりやすい!
@officialtatex
@officialtatex 3 жыл бұрын
true
@browneburbs5377
@browneburbs5377 Жыл бұрын
I have some problematic issues. While I am using a different car model, I don't think it should be any different than what this model provides, but regardless: I've followed the tutorial very well, but I've ran into two problems. When I add a Wheel Collider, it doesn't show up at all during the editing, unless I make a rigidbody component. But once everything was set up and handled, the car either bounces and flies in all sorts of directions that's not wanted, the wheels fall through the plane and into the abyss, or all the wheels snap to position 0, 0, 0. It's very infuriating and I'd love to get this fixed!
@sinanarts
@sinanarts 2 жыл бұрын
Hi, Can I use the same exact flow for a VR Car simulation.?
@drewvananne1796
@drewvananne1796 3 жыл бұрын
Exactly what I was looking for, great tutorial!
@kimjongun5739
@kimjongun5739 2 жыл бұрын
Does anyone know why my current break force in the inspector tab stays at 0 (whenever I change it just goes back to 0) when I start playing my game?
@peterbutterfield1153
@peterbutterfield1153 4 жыл бұрын
So the moving / driving is working fine i changed the motor a bit to suite my little game but the breaking just is not working iv tried removing the "isbreaking check" on the line 52 like you said to another person in the comments and i tried what another person said to that reply and neither worked well the original worked kinda where it breaks but then stuck with the break i also tried a few solutions i thought of but non of them worked mainly one that checks if break force is 3000 then check if space is being clicked make the motor torque to the breaking force that is required to stop the car from moving. Any help would be great
@marcosbenedico7304
@marcosbenedico7304 4 жыл бұрын
Same problem
@NewEraGamersOP
@NewEraGamersOP 2 жыл бұрын
Any solution you got ?
@salmansaleem2191
@salmansaleem2191 2 жыл бұрын
bro, the car isn't moving with the arrow and WSAD keys, the wheels turn but the car doesn't move forward or backwards please help thank you
@davekomen6600
@davekomen6600 2 жыл бұрын
I can't edit the speed and everything in the script. so i cant adjust the speed, steeringangle and brakeforce. Can u help me plz?
@megozcreed5196
@megozcreed5196 4 жыл бұрын
if I want the car to apply brakes as soon as I release any of the W S or Up Down buttons , what should I do
@Randomiz8orinator
@Randomiz8orinator 4 жыл бұрын
try reading the input.GetKeyUp method
@megozcreed5196
@megozcreed5196 4 жыл бұрын
@@Randomiz8orinator well i knew about them , I was meaning how to stop the car momentum , what code to put in the get key up func. I tried motor torque =0 Brake torque = Mathf.infinity But it still didn't stop as soon as key up So had to play with the rigidbody velocity for it to work.
@thaddeusnoffsinger2410
@thaddeusnoffsinger2410 3 жыл бұрын
Did you figure this out? Having the same question.
@nbgtube468
@nbgtube468 2 жыл бұрын
I’m having problems where the wheel colliders start to push away from the vehicle making it float, does anyone know how to fix?
@HitesH3D
@HitesH3D 3 жыл бұрын
I made the car with a fully functional car controller. it was working fine but when I use the same script and method on the new car mess it's not working. well are rotating but the car is not moving. any solution.
@elicopter_go_brr
@elicopter_go_brr 3 жыл бұрын
so remember...this tutorial is VERY SIMPLE!
@francek3892
@francek3892 3 жыл бұрын
Unity doesnt support rigidbody, we need a new tutorial lol
@ImScorpy
@ImScorpy 2 жыл бұрын
Note to people trying to make a Vehicle controller: DO NOT use Time.deltaTime on the motorTorque code
@walney2008
@walney2008 3 жыл бұрын
I put the wheel configurations as in the video, but even putting a mass of 50000 the car will still be lifting, what can it be?
@leonamferreira8053
@leonamferreira8053 3 жыл бұрын
try changing the suspension spring to 90000 and damper to 9000 on the wheel collider. Remember to change it for every wheel collider on each wheel.
@sebasA
@sebasA 2 жыл бұрын
Thanks, how can I do to stop the car slowly while Im not pressing up key with just the friction? Actually the car never stops, just with break.
@iRuR
@iRuR 2 жыл бұрын
W is for throttle, S is for brake, Space is for handbrake i think
@luanayres9418
@luanayres9418 Жыл бұрын
I'm using a model car from the polygon city pack and I get a error: "Non-convex MeshCollider with non-kinematic Rigidbody is no longer supported since Unity 5". I noticed too that the wheels already have a sphere collider, but i don't know how to adapt it to the script. I'm new to unity, please someone help.
@rajdeepdas86
@rajdeepdas86 3 жыл бұрын
Awesome hands-on tutorial. Can you please do a similar tutorial for bicycle?
@trunkmonkey5749
@trunkmonkey5749 3 жыл бұрын
I'd just take away a set of wheel colliders and add a bike model. I think it'd be very similar to the car.
@filippodeluca9464
@filippodeluca9464 3 ай бұрын
my wheel detacted from the car and go on their own, how do you fix it please
@julioaviles8125
@julioaviles8125 Жыл бұрын
what did you press on 5:43 to change only the 2 you needed
@bellanurhaliza5471
@bellanurhaliza5471 3 жыл бұрын
Why every time I play, the object always bounces?? And is each version of unity, the script is also different? Please help me
@HATL201
@HATL201 2 жыл бұрын
Thanks a lot for the project dear.
@edmashokmusic1692
@edmashokmusic1692 Жыл бұрын
For all those looking for car not moving after applying brakes. read the video description
@toaster-chan7386
@toaster-chan7386 3 жыл бұрын
So I was wondering, what would I do to keep the max speed the same but increase acceleration? Would it be like, increasing the motor force and placing a basic "if-then" statement to stop it exceeding a certain speed?
@flatikk
@flatikk 2 жыл бұрын
You could have it so that when you press the gas, it takes a certain time for the motor to reach the target torque, either using curves or basic script math/logic. Simply put, keep the maximum output of the engine unchanged but make it be achieved quicker or slower.
@EmperorStick
@EmperorStick 3 жыл бұрын
I just have one problem with the camera… when I flip the car, which is sometimes possible, the camera goes under the ground... Can you help me? Thanks :D
@Sweet-z8m
@Sweet-z8m 3 жыл бұрын
why are we using SerializeField instead of the normal class. I just want to know
@ramaarya3
@ramaarya3 2 жыл бұрын
Thankyou so much, you're lifesaver.
@HilalWaul
@HilalWaul 2 жыл бұрын
can someone explain to me, what visual studio extensions used on this video ? especially for the auto methods, auto type and colorize ? thank you
@virxest
@virxest Жыл бұрын
Even these tutorials are one big headache. When I finally get to the "Asset Store" and downloaded this package, I press "Open in Unity" and nothing happens. I already need a tutorial for this tutorial. I could only download but how do I "Import"?
@juleswombat5309
@juleswombat5309 2 жыл бұрын
Cool Nice and Straight Forward.
@ZAYMANGAMESTUDIO
@ZAYMANGAMESTUDIO 2 жыл бұрын
Hi, my issue is that I don’t want to use only pc to brake the car, but also my joystick
@derickchan3638
@derickchan3638 3 жыл бұрын
when i try to turn left or right when its reach high speed how to make the car not flipping should i change the mass of the car and the wheels?
@lukasriedl8859
@lukasriedl8859 4 жыл бұрын
I modeled my own car and everything works fine, except for the Wheel Transforms. They rotate in a weird way around the car and not around themselves. Is there any way to fix that? Thanks in advance.
@alexandru-cristianpop7099
@alexandru-cristianpop7099 4 жыл бұрын
Take one wheel mesh and make it wheel collider object child. Reset the transform of the wheel and then put it back in the mesh section. Repeat for the other 3 wheels. Worked for me
@lukasriedl8859
@lukasriedl8859 4 жыл бұрын
@@alexandru-cristianpop7099 It seems to work but the only problem is the scale. I have to set the scale to 100 but then the error occurs again.
@lukasriedl8859
@lukasriedl8859 4 жыл бұрын
@@alexandru-cristianpop7099 I fixed the scale thing. There was a problem with the blender export. Now i still have the problem with the rotation and what you suggested did not work.
@alexandru-cristianpop7099
@alexandru-cristianpop7099 4 жыл бұрын
@@lukasriedl8859 I'm sorry then, bro
@Leo785
@Leo785 4 жыл бұрын
@@lukasriedl8859 put the origin of your wheel mesh in the center of your mesh.
@nunotorres636
@nunotorres636 3 жыл бұрын
hey man , can u tell me why my car is not steering anything. he just urns a little bit but is very slow turning
@Coding_technique123
@Coding_technique123 7 ай бұрын
Can I run this game by just using this project file From the GitHub after extract
@jvstAsYouAre
@jvstAsYouAre 3 жыл бұрын
I have seen a couple of comments asking how it could be possible for the wheels to be rotated 90 degrees when you start the game but nobody has been able to answer the question. PLEASE HELP!
@maximizer174
@maximizer174 3 жыл бұрын
yeah, me 2...pls help
@a7medabdalhadi780
@a7medabdalhadi780 3 жыл бұрын
I think u made ur own car then imported it into unity I faced this problem also and it is easy to fix, u have to change some details in the script -First go updatesinglewheel method and enter new Quaternion called it "Rightrotation" or any name u want to -next write down this line: Rightrotation=new Quaternion (rot.X, rot.y-1,rot.z,rot.w); //this line should be written after Wheelcollider.getworldpose... etc// -Then change wheeltransform.rotation into: wheeltransform.rotation= Rightrotation; I wish this could help u :)
@chrisliyasstorytime3233
@chrisliyasstorytime3233 4 жыл бұрын
Sorry but can you tell me what is the reason my car still flips even if I change the spring and damper value ?? Please help
@nsb_tv5820
@nsb_tv5820 3 жыл бұрын
the only word is perfect for this video
@daniellundholm7079
@daniellundholm7079 4 жыл бұрын
When we start creating code in C#, you delete the first lines and replace them with "FixedUpdate". That doesnt appear for me. There are no such thing as "FixedUpdate" in visual studio. It bothers me because it is a really nice tutorial otherwise and I want to finsih this so bad. Please help!
@あれくす
@あれくす 3 жыл бұрын
Fixed update is a built in UNITY FUNCTION part of ALL MONOBEHAVIOUR classes. Visual studio is CLUELESS to FIXEDUPDATE unless you run the unityaddon for visualstudio which you should have if you are using unity.
@RAVuu_
@RAVuu_ 4 жыл бұрын
It shows that currentsteerangle is not a variable, and adding one messes it all up. Do you know what I did wrong? Did I miss anything?
@nieruseqq4633
@nieruseqq4633 3 жыл бұрын
I have this same error do you fix that?
@josemariatoledomoreno1803
@josemariatoledomoreno1803 3 жыл бұрын
Hi, i have a problem, when my car touch the ground it go up again quickly and it doesnt stop to go higher. Could you give me a solution?
@dradex9562
@dradex9562 3 жыл бұрын
if you watch it after he finishes the script you have to change the mass of the rigid body from 1 to 1500
Basic Car Movement in Unity
16:04
b3agz
Рет қаралды 102 М.
Arcade Style Car Controller || Unity Tutorial
21:20
SpawnCampGames
Рет қаралды 92 М.
Friends make memories together part 2  | Trà Đặng #short #bestfriend #bff #tiktok
00:18
버블티로 부자 구별하는법4
00:11
진영민yeongmin
Рет қаралды 24 МЛН
Seja Gentil com os Pequenos Animais 😿
00:20
Los Wagners
Рет қаралды 47 МЛН
Life hack 😂 Watermelon magic box! #shorts by Leisi Crazy
00:17
Leisi Crazy
Рет қаралды 80 МЛН
20 Advanced Coding Tips For Big Unity Projects
22:23
Tesseract
Рет қаралды 193 М.
How I made my own Arcade Racing Game
6:15
Obvious Dev
Рет қаралды 84 М.
How Two People Created Gaming’s Most Complex Simulation System
38:54
ThatGuyGlen
Рет қаралды 1,4 МЛН
Arcade Car Driving in Unity
32:48
gamesplusjames
Рет қаралды 124 М.
Unity3D How To: Driving With Wheel Colliders
30:17
Renaissance Coders
Рет қаралды 217 М.
Making Custom Car Physics in Unity (for Very Very Valet)
22:48
Toyful Games
Рет қаралды 130 М.
I Wish I Had Known This Before I Started Unity Game Development...
11:11
I Optimised My Game Engine Up To 12000 FPS
11:58
Vercidium
Рет қаралды 703 М.
How to Create Road Tracks Using Road Architect in Unity
14:58
Friends make memories together part 2  | Trà Đặng #short #bestfriend #bff #tiktok
00:18