Unity 3D Realistic Driving Simulator || Part 1 || 2018|Speedo/Fuel System

but if you close you Hey, guys, welcome back to my video my name is Asish Sharma Sorry, guys for not being much active in youtube but i’m finally back with a unity tutorial series, in this series We will learn to create a drivable vehicle it contains working lights speedometer fuel, system including refueling System player which is going to be a fps first person controller It also allows you to enter and exit the vehicle ai such as Vehicle ai it will follow every road rules such as a speed limit and stopping on the traffic lights This, series will, also contain traffic light System speed cameras and much more it contains ticket system for breaking, broad rules such as running a red Light or speeding and much more stay tuned for more updates thank you guys all Right guys, let’s get it started So first of all what you guys need to do is go to the Link in the description and get the simple cause back So this is what you need, for this video it includes two buses and six vehicles So import download them and import them into your Project after that, what do you, want to do is go to assets import package, and select vehicles Well that will give you use a stranded assets vehicles cars Prehaps, that will give you, this car, so to open that one go to your stranded assets vehicles cars Prefab and this car drag it on to your scene after you’ve done that one Let’s test, this car so right click onto, hierarchy right click camera and let’s put our camera here so press control shift and f while selecting camera – you put yours camera on you under view and your under view of the this Screen, and press play As you can see i can, drive this vehicle But, we want to make the vehicle that, we got from the isis store? so So we’re going to get this vehicle to drive as like, this vehicle so what you? Want to do is go inside the simple vehicle prefabs and drag any vehicle that you want i’m going to use this vehicle and alright, so let me give you, the Shortcut, for the tools so if you press w it will give you the transform tool if you press it will give you the rotation tool, and If you press r. You will give you, this scaling tool, what you, want to do is make sure you match the Scale of the vehicle with, this vehicle that, we have on here by default so It does not have to be perfect That one will do? Yep, that looks pretty good so what you, want to do next is? You’ll drag, this vehicle inside this car So let’s drag it inside that car. And let’s test it how it works As you can, see we can, drive but this vehicle We can, still see it will and the will of the vehicle the What vehicle is turning up the one with on the white yellow vehicle so, we want to do is will replace the? Wheel hubs, and will collide us and will messes with. This vehicle What we’re? Gonna, do first of all what we’re gonna do is go to the sky car, and hide it so that way we get the view of this vehicle and Open that vehicle and rename all these objects that Will make our job way easier so we’ll say this one is body This one is front left we’ll Wiener we just gonna, say front left and this one is front right and this one is rear right and this one is Rear left After you have renamed all of it it’s time to replace this v this wills with the other vehicle so select the car That is from the stranded assets? Which, has the car control script

Under the car control s script and under the wool messes you can, see the Element 0 1 2 3 what these are the Will masses what you want to do is you, wanna drag this Onto this one so what you’re gonna do is this, is sky car, wheel front left so you’re Gonna get this front left, and drag it And this is front right? Get this front right and drag it there this is rear right so this is real right Put it there and real left goes there after that you’re all done next thing to do is Make, sure the clatters, we don’t need to worry, about it It’s not aligned but it’s Cool just give it a alright But, we will just fix it a bit so this one is fine inside the collider front one is Finds that one button is not fine so we’ll scale it bit up But that’s good make, sure it’s bit down, so it matches with the that one there All right after that’s done go inside the wheel hubs which, is there which is under the colliders and? Let’s go, this ready, view our 2d. View so by pressing this square and Zoom in this is fun right i think i was the right one yep So front right she came in and Align, it with it will Go, to this view. And put it in the middle roughly middle and we’ll go to the rear right go, to that view and drag that and align with the rear view of the yellow car and Go, to back, me make, sure it’s on the middle roughly middle and go to the rear left Let’s line the back fist and drag it back a bit up And let’s see yep there you go and the front left Drag it up a bit go to the front view. And put it in the middle all right that’s all So, that’s done let’s test the game As you can see the wheels are finally turning on this yellow, vehicle it’s drivable Thing is fine All right next thing up, we won? Get the speed meter of this vehicle so what, we want to, do, is i’ll put the link in the description for you guys, to download all of this files all this texture So what we wanna do is drag all of this to our scene so go to? Create a folder material and place all of this in there Alright after that is done? We’ll create a, right click you i will create an image that will take that As you can see it’s there What, we want to do this is going to be our speedometer? put that on the right side and We want to put this emails on that one so like that if you If you drag it it won’t work so what you want to do is select this the emails Gotta take the tab and set it to spite duty and ui and hit apply after that You select. These image and drag this onto the sprite there you go that’s a nice Speedometer press our scale it up align it and they go probably bit smaller now this one in blue Place it right looks good Fits that part is done what you want to do is rename this to speedo? You know i believe yep and? bar click create empty and say numbers Numbers, what do you, want to create a ui text And you recreate numbers like 10 20 40. 50 that will this bet That will work as your speed

Indicator so if you, make it read that So you, wanna create all in a circle so 10 20 40 all right i’ve already, done that one so we’ll do is it’ll grab that one in there All stays inside my numbers and Unhide that one they go Alright it’s not perfectly managed so Britain white snow springs so let, me make these So that way, we can. Adjust it Speedo, there you, go, and put the numbers on the slide up Alright perfectly matched and we want to put these numbers? Inside this speedo, and inside this speedo, we also want to create a ui image So this is the already radius or something one sec guys yeah, this for this one so what We want to do is click on that one do the same thing sprite and apply and click on the image and drag it onto, the sprite there you go and resize it let’s kill it Probably, that much will do All right save it and now it’s time to Is that good yeah now it’s time to script If you, play nothing you laughing because, we have not done anything spit spit o’meara, is there but it’s not going to work So next thing up Let’s go to our script folder create Icy surface, i will name it speedo and hit enter Open it are we gonna open it on visual studio? so after that one opens So after that one opens what, we want to do is we’ll say public? rigidbody And we’ll say? We’ll say vehicle vehicle and semicolon and will create one more public will say float i Fell away to float and would say mean low city Velocity and we’ll give it zero point two one one five f And we’ll create a public float, and we’ll say max velocity vo V-loc idea velocity and will they give this value of? 0.9. F Semicolon all right after that we’ll say unstart so this voice statements, when the game starts so, we’ll say emails i Will also have to create one more tank since a private private image i am a z i am a z image Next day it’s on capital letter and will say i am in the image So i know, why this is giving me wrong? but yeah So after that one will set on the start and it start image equal to get component get component create that one and Two brackets semi-colon so inside this we’re, gonna write image So what, we want to get is image? And after that on the void update we’ll say so this is the

Frame, by frame so we’ll say image dot feel i am Or un t so fill amount, we are referring to on the Unity, let me quickly say, we are mix it and also make sure it is the image type of this Radiator is on the field not on this simple, and make sure it’s on Radio six 360 and button, and that will give you this night nice little And so we fill amount this stroke is what? We are referring to this one so this script is referring to that one? all right After that is done we’ll set equal to vehicle? So that vehicle is this one so that is getting the big ridge it body, and we’ll say velocity velocity dot magnitude magnitude Divided by mean velocity Divided, by max velocity max Max velocity and we’ll give it a semicolon after that one that started and we go to unity Make, sure we turn, okay all right That just eva’s could, not be found the reason, why, we? Ignore ignore all the reason, why, we’re getting this error is we have not set you either so using Unity ends in dot ui All right now it should fix the error if we got unity This, would fix up there you Go, and let’s go to the image and drag this script there and this vehicle rigid Body, should be inside disguise i drag this car inside bear and let’s hit on play let’s see how it works Play it as you can see the radiator is getting super fast Fix this You have to pair on with this settings are you can, go to the script and change the, swap this cellmaxx velocity max velocity Mean velocity, this, may fix the issue Nope all right so you have to change some settings here So if you said that number – probably – all right so the more you set the better you get safari Let’s see what it will t All right there you, go that’s it it works you can, change the settings You’ll go to the camera will put the camera right here or shift f and We’ll put this camera inside the car, and let’s play Alright as you can see the speed is increasing Yeah, i don’t feel, like it’s realistic Spring over it what we’ll do is we’ll go to the image and we’ll say 50 That’s how, this will go All right this looks bit realistic this is 40 we’re using kilometer actually we’re not using miles Because i’m in australia that’s what, we use i don’t feel like it think, i may need 60 All right so this is twenty forty sixty One sixties this much eighty unread round this one is all right there are with the settings until you get the right one and Yeah, thank you for watching guys and in my next video, we will learn to create this, fuel, system and Many more to come

Thank you guys and see you in next video