I'm Turkish and my purpose of watching you is that there is no Turkish person who makes videos, so I made a car game and I owe it to your free script, thanks man.
YOU ARE THE EMBODIMENT OF A GIGACHAD THANK YOU MY MAN
Bro, you helped me a lot, I was already freaking out why the code I was using was giving me problems but I found this video, another subscriber
Awesome, thank you!😀
nice video, mate. I was able to get it to work nicely. How would I go about having the camera free look whilst using the car?
Awesome, thanks alot sir
This really helped me! One issue though, the rear wheels are very far away from the car, any tips?
Hi! I have a question about the car. When i play the game, my front left and rear left wheels are sticking out a little further than i intended. Is there a potential fix to this?
Thanks Bro!
WOW! I'm searchig hurs for this and finally found 'em thanks bud!😜
THANK YOU SOOOOOOOOO MUCH
So the wheels decide to move to the middle of the underbody and the spoiler falls of any fix?
Love you bro
I have a problem with the wheel transform when I put it on the wheel the car starts to do back flips and the wheels move away from the car I don't understand I did the whole tutorial correctly but it makes me feel like that🤔🤔
I have a little issue with the wheels, they're rotating but not using the centre of the wheel for it. They rotate in a open "circle", I mean, they move from the centre and create their own circumference. Trying to apply the script to truck wheels so they're not "small wheels". Thanks in advance.
Had the same issue, it doesnt have to do with the wheel size, the center point of the wheel is screwed up (from the 3D file), i used my own model (using blender) to create the car, when you export the car wheel, make sure it's on 0,0,0 (xyz) coordinate otherwise it do the ohio wheels
plz man tell me bro how can i just make a ui button witch rotate my car backward and forward
i have problem this car is very good but very slow new script? or something in new in unity and this is very hard for me
can you help me my car is very slow . i tryed everything but this not work
when i made my wheels i had to rotate 90 on the z. Your script flattens them and if i put them under parents then they end up squished.
Vehicles slide sideways when going on on slopes. any fixes?
I'm having trouble with the cinemachine when the car is reversing. The camera doesn't go far behind or infront of the car while reversing but rather the car comes really close and occupies the whole screen. Any suggestions please?
you can click on virtual camera and then in inspector click on body and set all damping to zero i think it should help
thanks for the response but I finished my first game 1 month ago! I ended up not using cinemachine but rather just manipulating the camera's movement instead. : )
great video and help with setting up colliders, can this script be adjusted for mobile environment? taps on the screen?
please make complete course of 3 to 4 hours on this where you teach from importing assets to build complete car game or any transport game
I got my vehicle to work but i would like to have sound..i have no patience for coding which upsets me 😥
How do i fix it if the wheels are sideways?
hi, when i apply the script, my wheels flip by 90 degrees on the z axis and they rotate around the x axis. what do I need to change in order to get it right?
obrigado cara graças a ti criei meu primeiro jogo
how do i improve my starting speed? I cranked the motor force to like 999999 but it still takes forever to build up momentum.
I would add an impulse force during the first frame that the button is pressed, along with the normal car force
what is your drag on the rigidbody of the car? for me i had the same problem because it was at 5. if i put 0.1 then it works nicely
it wont let me drive and rolls backwards until it falls pls help
my car is stuck on one place but wheels are working
its work but i got one problem, the movement is slow, like heavy, i put motor force, break force and macx steer angle like in the video but still slow, anyone can help?
I recommend you change up the value of the variables. Let me know if it helps
my wheels get flung off
My car starts shaking when i drive do you know how to solve it?
even with the car's mass being 1300, it still flies upward and eventually falls down. I tried raising it A LOT and a little, but it only slows the rising of the car. Not sure what I've done wrong but I did exactly what you did and used the same car model...
its also when I begin to move forward, it just flies up into the air slowly
What are the controls for the movement cuz i have been typing WASD and changing valus weight brake and have also readjusted the colliders but still no results i.e. movement
The tutorial doesn't mention it, but you need to install the new unity input system package under Unity Registry
the controls for movement are on the input system using unity. you will have to add the package as said below and also add the using.UnityEngine.InputSystem for it to work on the horizontal and vertical axes. you can see the buttons in the project settings under input.
I cant turn left or right or slow down my car help
thank you
After Running A game my car flying in air not stop on ground I'm follow your all steps but car not running on ground I'm copy your every step but didn't work please help me
how do i make the floor like that?
my car shaking too much i have tried everything but nothing working pls tell me hoe to make car more stable
hi I have a problem. my cars wheels are turn 90 degree when I start the game
and there is no info about this. can u help
answers.unity.com/questions/1357259/how-do-i-get-my-wheel-mesh-to-rotate-on-the-proper.html
Hope this helps
👍
mine the wheels arent moving
but the car is'
when i use premade prefab from asset store script(and other similar scripts) works as it should, but when i make my own car using basic geometry in unity, wheels transform and car flies into space. Or when i use car asset and wheels from different asset all the wheels become right wheels. Where am i wrong????
@@goforit738 i found solution, if your wheel is bugged, use negative scale, like if you have 3.3.3 scale use -3 -3 -3. Unity is not suitable for transform manipulations so better use other 3d modelling apps and import to unity
How the car are moving if we haven't write a code for key press to left right or forward
i want to make car drift like nfs , dirt 3. could make video?
Hey! I have a very annoying problem. when I add the wheel collider, it is not visible at all. How can I fix this
Make sure any of the parents has a rigid body. If its still not showing try clicking on the car Prefab wheel collider must be shown there.
thx❤
i don't get the thing under the script, where I can change the variables
Please ask me questions if you are stuck
I want to make the car drift at the press of a button but everything I tried looks unrealistic or the car looks like slipping not drifting.
First i need to congratulate you
Thanks a lot
Can u please help me how can i use my mouse movement for left and right
Also can u please tell me how can i display the speed of the car
Box collider 2d?
my car is extremely easy to flip over, all my settings are the same as yours and i dont want to freeze the rotation. is there a fix to this please?
car movement too slow. I tried increasing the acceleration (motor speed) up to 1 million but car still too slow. Need help
Adjust the friction of the wheels! Your wheels are probably slipping, basically spinning in place, but it's really hard to tell. Reduce forward friction extremum slip to like 0.001 and iterate from there.
I am having a problem that the car is falling down
I changed the spring and damper to the same values in all wheel colliders, but my car still flips over really easily.
sounds like the mass of the car is too low. if there is no weight to support the force the flipping part will happen. try adding mass to the object in your rigidbody
The issue is the UpdateWheels function. Im not sure what it is for though, I wish they explained it in the video.
hey my car isnt braking well and takes ages to brake how do i fix this???
My cinemachine camera shakes heavilty.
i tried the damping to set to 0 in the aim tab but nothing.
Adjust the horizontal damping to 0.1 instead of 0, and you'll thank me later. :)
My wheels dont even move and the top of my car just fully comes of as soon as I press start. Any help?
If you for some reason dont want to click in the bio for the code here is it:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CarController : MonoBehaviour
{
private float horizontalInput, verticalInput;
private float currentSteerAngle, currentbreakForce;
private bool isBreaking;
// Settings
[SerializeField] private float motorForce, breakForce, maxSteerAngle;
// Wheel Colliders
[SerializeField] private WheelCollider frontLeftWheelCollider, frontRightWheelCollider;
[SerializeField] private WheelCollider rearLeftWheelCollider, rearRightWheelCollider;
// Wheels
[SerializeField] private Transform frontLeftWheelTransform, frontRightWheelTransform;
[SerializeField] private Transform rearLeftWheelTransform, rearRightWheelTransform;
private void FixedUpdate() {
GetInput();
HandleMotor();
HandleSteering();
UpdateWheels();
}
private void GetInput() {
// Steering Input
horizontalInput = Input.GetAxis("Horizontal");
// Acceleration Input
verticalInput = Input.GetAxis("Vertical");
// Breaking Input
isBreaking = Input.GetKey(KeyCode.Space);
}
private void HandleMotor() {
frontLeftWheelCollider.motorTorque = verticalInput * motorForce;
frontRightWheelCollider.motorTorque = verticalInput * motorForce;
currentbreakForce = isBreaking ? breakForce : 0f;
ApplyBreaking();
}
private void ApplyBreaking() {
frontRightWheelCollider.brakeTorque = currentbreakForce;
frontLeftWheelCollider.brakeTorque = currentbreakForce;
rearLeftWheelCollider.brakeTorque = currentbreakForce;
rearRightWheelCollider.brakeTorque = currentbreakForce;
}
private void HandleSteering() {
currentSteerAngle = maxSteerAngle * horizontalInput;
frontLeftWheelCollider.steerAngle = currentSteerAngle;
frontRightWheelCollider.steerAngle = currentSteerAngle;
}
private void UpdateWheels() {
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;
}
}
my car flips every time I hit the play game mode , Idk whats happening can anyone guide
thnx
this video: about how to script a car in unity
me: BumBLBEEE YAYYYY!!!!! 😃😃😃 🤖
idont get the script to work
Thank you so much this video really help me it is easy to understand and now I can do my Final Project in our Gamedev subject I will like and subscribe the video and channel in return
my car is mooving very very slow, it's hardly belive that it's moving
this is convenient if you dont know how to code!
man, how to make infinity road like yours?
Add a plane to your scene and scale it up. Then you add a texture to it 👍
@@SigmaLigmaChannel one more thing my car is rotating after hitting the plane.
I mean: I press play mode, then my car go down when hit the plane it started rotating, i think its because of colliders maybe. could you help me, please
Can you plz make video on mobile controller of this script?? Plz🙏🙏🙏🙏
Thank you for your suggestion. Yes, there will be a tutorial on a mobile car controller in the next couple of weeks or so. Great idea!
@@SigmaLigmaChannel Oh nice! Upload tutorial as soon as possible :) Edit :- I need it too :D
@@MutantBrooo4321 Probably will be at the end of next week, because I’m already working on another video and don’t have a lot of time currently
i got 3 errors
the namespace '' already contains a ddefinition for 'carController'
Type 'CarController' alreaddy defines a member called 'FixeddUpdate' with the same parameter types
Type 'CarController' alreaddy defines a member called 'GetInput' with the same parameter types
I think you should learn the basics of unity first before making this
My car keeps falling thru the ground
Make sure that you follow all the steps carefully. This probably has to do something with the colliders.
My car is fliying wegen I play
my wheels are bugging out
I had the same problem. You have to give the Body of the Car a Mesh Collider and then turn Convex on. I hope I can help you with this!
where is the script
I think you were "inspired" by "b3agz" video. Because *many* things are similar...🤨
bro my car is flying
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CarController : MonoBehaviour
{
private float horizontalInput, verticalInput;
private float currentSteerAngle, currentbreakForce;
private bool isBreaking;
// Settings
[SerializeField] private float motorForce, breakForce, maxSteerAngle;
// Wheel Colliders
[SerializeField] private WheelCollider frontLeftWheelCollider, frontRightWheelCollider;
[SerializeField] private WheelCollider rearLeftWheelCollider, rearRightWheelCollider;
// Wheels
[SerializeField] private Transform frontLeftWheelTransform, frontRightWheelTransform;
[SerializeField] private Transform rearLeftWheelTransform, rearRightWheelTransform;
private void FixedUpdate() {
GetInput();
HandleMotor();
HandleSteering();
UpdateWheels();
}
private void GetInput() {
// Steering Input
horizontalInput = Input.GetAxis("Horizontal");
// Acceleration Input
verticalInput = Input.GetAxis("Vertical");
// Breaking Input
isBreaking = Input.GetKey(KeyCode.Space);
}
private void HandleMotor() {
frontLeftWheelCollider.motorTorque = verticalInput * motorForce;
frontRightWheelCollider.motorTorque = verticalInput * motorForce;
currentbreakForce = isBreaking ? breakForce : 0f;
ApplyBreaking();
}
private void ApplyBreaking() {
frontRightWheelCollider.brakeTorque = currentbreakForce;
frontLeftWheelCollider.brakeTorque = currentbreakForce;
rearLeftWheelCollider.brakeTorque = currentbreakForce;
rearRightWheelCollider.brakeTorque = currentbreakForce;
}
private void HandleSteering() {
currentSteerAngle = maxSteerAngle * horizontalInput;
frontLeftWheelCollider.steerAngle = currentSteerAngle;
frontRightWheelCollider.steerAngle = currentSteerAngle;
}
private void UpdateWheels() {
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;
}
}
Code
ismit lisanced
Do you mean is it licenced? If so, you can use this script for any game you want. Even in commercial uses. Hope this helps!
aint no way anybody is gonna use it in commercial use @@SigmaLigmaChannel
bro wake up and decided to copy others
My car shakes violently, i cant figure out why, can somebody please help me?
@@duraeman2893 did you change that option in 3:57 in the AIM tab? Because there is similar one above this tab.
bad
dude give me script i will copy paste
dude watch video i will help
i@@SigmaLigmaChannel i already watch your video many to see script but u didnt showed whole script thats why
Are you deaf?@@UnlimitedUnity
@PrismUnityTutorials what your mean bro. can u just paste script here pls
Have you watched the video with sound on and are you able to hear properly?