Making Custom Car Physics in Unity (for Very Very Valet)

Ойындар

A detailed look at how we made our custom raycast-based car physics in Unity for our game Very Very Valet - available for Nintendo Switch, PS5, and Steam.
BUY NOW!! toyful.games/vvv-buy
~ More from Toyful Games ~
* Physics Based Character Controller in Unity: • Making A Physics Based...
* Instant "Game Feel" Tutorial: • Instant "Game Feel" Tu...
* The Toyful Blog with even more developer deep dives - toyful.games/blog
* Get Very Very Valet now - toyful.games/vvv-buy
* Download the FREE demo on Nintendo Switch today - toyful.games/vvv-di
Video sections:
0:00 - Intro
0:28 - Car Physics Overview
2:43 - 3 Forces per Tire
4:36 - Force #1: Suspension
12:26 - Force #2: Steering
18:40 - Force #3: Acceleration/Braking
21:59 - Outro
#VeryVeryValet #NintendoSwitch #MadeWithUnity #GameDev #IndieDev #tutorial #tutorials #howto #PS5 #steam #epicgamesstore #Windows #Mac #PC #CouchCoop #Multiplayer

Пікірлер: 385

  • @kalkatos
    @kalkatos Жыл бұрын

    If we had an award for best car physics tutorial on KZread, this one would be - hands down - the uncontested winner!

  • @f11bot
    @f11bot Жыл бұрын

    How doesn’t this have more than a million views, seems something out of a popular TV Series, it’s so refined and easy to understand!!

  • @Colonies_Dev

    @Colonies_Dev

    Жыл бұрын

    this is the only video i CANT understand, it seems most of the setup code is missing and it immediately throws extremely fking vague keywords like tiretransform and vague references to rigidbodies that WERENT visibly declared. i have to throw this video out of my mind and move on to a different video on the same topic. its really fucking irritating.

  • @trashcaster

    @trashcaster

    Жыл бұрын

    @@Colonies_Dev What you can do to get this to a more useful state for yourself, put each of these into their own functions, and have all undefined variables be parameters in the functions. In the car's controller script, in FixedUpdate, iterate over an array of Transforms (or components called Wheel that have a transform defined and publicly "gettable") you define as the various wheels. With each wheel in your foreach loop, you ray cast from the transform it has, along the transform's "down" direction (-transform.up), with a maximum distance of springMaxLength + wheelRadius (you define these in each wheel, but note that the max length of the spring isn't going to tell you the current length, the hit will. Current spring length is equal to the raycast hit's distance minus wheel radius). The success of this Raycast is "rayDidHit". I recommend using the wheel component purely as a way to define multiple wheels and their transforms and spring/radius data, possibly to adjust rendering stuff for the wheel. Control the vehicle entirely from a Vehicle Controller script using the loop system, to reduce the number of monobehaviour components used for performance. Arguably, you could make wheels not be components, but just a struct that has the values and transforms defined, so it is used as references only, and can be entirely modified in the editor on a single object.

  • @CosimoDavideViggiano

    @CosimoDavideViggiano

    Жыл бұрын

    @@trashcaster I understand the irritating, I also tried to get this work but I only can get work the Y-axis forces (suspension) when I try to add the accelerate/braking force, the car move in a way that is unexpected. So, how all this force are added to the Rigidbody, does order matter? Why not show the entire code? The theory is fascnitang but...need to see it in practice

  • @modjok127

    @modjok127

    Жыл бұрын

    @@trashcaster i actually see a problem with this approach, when the wheels get contact, let say after a jump, does it not "suck" the car to their contact point ?

  • @tiernanmccarthy

    @tiernanmccarthy

    Жыл бұрын

    @@Colonies_Dev I hope you found it useful in the end. But if you didn't I would say this is more of a lecture for working something out yourself than a tutorial. It took me a while to construct something out of it, but I have drivable vehicles in a smaller project at work from it. This was a crash course on how to approach the problem, and now the car rig is very much my own.

  • @Why485
    @Why485 Жыл бұрын

    This is now the definitive "car physics" gamedev video I will pass around whenever somebody asks about it. The presentation is excellent and the info is great.

  • @_ahmedshalaby
    @_ahmedshalaby Жыл бұрын

    I cant emphasis enough how i love this type of videos, I really hope you continue give us more tutorial and tips and tricks along the way, great job.

  • @ririgamesofficial
    @ririgamesofficial Жыл бұрын

    This is so incredibly well done. Been banging my head for the passed couple of weeks to try to understand how car physics work and this method is the one that makes the most sense to me.

  • @reversible8740
    @reversible8740 Жыл бұрын

    Loving these videos. Really nice rigid body controls in unity with explanations are hard to come by. Definitely gonna check out the game.

  • @oldshamen
    @oldshamen Жыл бұрын

    How you illustrate and explain each part is really amazing. Top quality tutorial that focuses on explaining the why instead of just spending 30 mins typing code. Love it.

  • @reihanmohamed6718
    @reihanmohamed6718 Жыл бұрын

    The quality of the video is so good. I have been watching many videos about car physics in games and this is one has given the most explanation in a very good presentation. Thank you so much. Have already subscribed.

  • @chienbanane3168
    @chienbanane3168 Жыл бұрын

    I didn't expect a tutorial to look this polished! Very informative as well!

  • @Bloodlinedev
    @Bloodlinedev Жыл бұрын

    This is absolute gold. I have wrangled with the buildin car for years now, this video makes it look super easy. Will def use this the next time I need vehicles. Thank you so much.

  • @QuadeZaban
    @QuadeZaban Жыл бұрын

    You guys are crushing it! These videos have been extremely useful. Thanks for the resources, and thanks for the great game too!

  • @boulder_dude
    @boulder_dude Жыл бұрын

    The way you broke down the physics with visuals and graphs made it easy to understand and implement. Extremely performant in comparison to calculating a Rigidbody for each of the objects. Thanks for sharing this concept, cheers!

  • @blinkachu5275
    @blinkachu5275 Жыл бұрын

    Thank you so much for this, I always struggled to understand the "side forces" but your simple explanation made them a lot easier to understand

  • @piyushguptaji402
    @piyushguptaji402 Жыл бұрын

    this was the best explaination i heard.... i love you man. unity's default wheel collider is sluggish, so i went for a raycast approach, i did achiece suspension, but had no idea of friction. i really appreciate you taking time to make all this illustration and explaining us

  • @luisfidalgo9128
    @luisfidalgo91284 ай бұрын

    This is content i would pay for! Understanding the physics and how everything works before any line of code is the best way to learn! Amazing video and thank you for taking the time to make it, with all the in depth physics explanation!

  • @njdarda
    @njdarda7 ай бұрын

    i think you struck a perfect balance between realism and and simplicity here. amazing job and great presentation too!

  • @williamchurch8401
    @williamchurch8401 Жыл бұрын

    This is incredible! Thank you so much for sharing this ingenious car system!

  • @Brovioli
    @Brovioli Жыл бұрын

    Please make more programming videos. Your explanations and breakdown of the topic was S Tier. So many other youtubers still leave me with many questions. But I was able to follow along and understand this the whole way through.

  • @guadog
    @guadog Жыл бұрын

    Thank you so much for breaking it down how it works in such an easy to understand way! This really helped me with a game I'm making, so thank you so much!

  • @LuRybz
    @LuRybz Жыл бұрын

    Knowledge and learning is gift that gives joy. Content like this is priceless, it turns my life more enjoyable. Thank your for sharing!

  • @OddStare
    @OddStare5 ай бұрын

    I love the simplicity of it, thanks for sharing this with such quality ! Less rigidbodies is always a win in my book

  • @jojo.s
    @jojo.s Жыл бұрын

    I was trying to understand the steering part on my own, and this explanation made it so simple and easy to understand. Thank you so much for sharing this knowledge!

  • @dziemon
    @dziemon Жыл бұрын

    This is a fully professional course video for free. Thank you so much! Good to see you still active here in the comments. I am tinkering with this concept on my own and found some success. Hope Toyful Games are still operating and you are cooking something new!

  • @neipo
    @neipo Жыл бұрын

    Such a good series thank you for making these

  • @devin18101
    @devin18101 Жыл бұрын

    YOU ARE MY SAVIOR, lmao thank you so much! This game actually looks pretty fun and I am going to check it out. I have been looking for a video like this for YEARS, and finally the youtube algorithm has connected us! I really do appreciate the depth and simplicity as well as the visuals to make it as easy as possible to really understand what actually goes on behind the scenes in a conceptual way.

  • @tageueland
    @tageueland Жыл бұрын

    This is exactly what I was looking for! Very easy to understand and implement.

  • @juanloutech2864
    @juanloutech2864 Жыл бұрын

    Perfectly explained basic car physics. Great job, amazing video!

  • @torryjaja
    @torryjaja Жыл бұрын

    this is absolutely fantastic, thank you so much for making this

  • @lucaswk
    @lucaswk Жыл бұрын

    These videos are simply amazing. I'm hyped when I see some uploaded. Thank you so much.

  • @andrewalex478
    @andrewalex478 Жыл бұрын

    Very satisfying and useful video tutorial! Great job!

  • @Glados44
    @Glados449 ай бұрын

    I buyed your game. 1000% Sure this is the best game. And the best video to explain how you made the car physics. You deserve everyone talking about this cause you are the only one out there making a well explained controller for cars. Thank you for this!

  • @drewbluewasabi
    @drewbluewasabi Жыл бұрын

    Legendary video. Legit would not have been able to make a polished vehicle system if it weren't for this video and the great visualizations!

  • @ChillGuyYoutube
    @ChillGuyYoutube Жыл бұрын

    this is an amazing tutorial hands down, there should be more game developers posting devlog-like videos on how their game works, it's so helpful to small developers!

  • @ElvishJumpSuit
    @ElvishJumpSuit Жыл бұрын

    I really enjoyed your way of breaking down the fun of your game into simple physics. Never seen a more obvious link to the modern relevance of the subject. I hope that my students will be inspired by your engaging delivery. There is a parallel universe where you are a cracking physics teacher!!!

  • @eldany_uy
    @eldany_uy10 ай бұрын

    I am Unreal user and This example applies perfectly because you're not focusing on the Engine but in the overal physics concept. Great Video!!!! SUBSCRIBED!

  • @psychedeliccoffee2737
    @psychedeliccoffee27375 ай бұрын

    Please make more of these dev-style videos. They are amazing

  • @f1van405
    @f1van405 Жыл бұрын

    Great job! Thank you very much for your tutorials!

  • @haikunHuanghk
    @haikunHuanghk Жыл бұрын

    finally, some one explained clear on Damping. :P Good job Toyful Games!

  • @sethsandwich
    @sethsandwich4 ай бұрын

    This was an incredibly good tutorial. Thanks so much for the effort that went into this 🙂

  • @MineXplayPL
    @MineXplayPL Жыл бұрын

    Awesome explanation, looked so compilcated and now it's so simple. Definitely buying the game also as a way to say thank you!

  • @tokyowarfare6729
    @tokyowarfare6729 Жыл бұрын

    Insante quality tutorial, the content, the visuals everthing is over the top

  • @tropochito
    @tropochito9 ай бұрын

    GOD, What AMAZING TUTORIAL!

  • @ravendave24
    @ravendave24 Жыл бұрын

    thank you so much for this in depth explanation! i love these kinds of videos!

  • @pove4266
    @pove4266 Жыл бұрын

    I was making a racing game as my project for finishing my degree. I will throw it away and start again copying what u did. Man if I can pull this off I think it is great. What a great explanation.

  • @YouCodeThings
    @YouCodeThings Жыл бұрын

    Brilliant breakdown!

  • @Vsev0l0d
    @Vsev0l0d Жыл бұрын

    Great stuff! Keep going, its very interesting game mechanic.

  • @gregoryhause00
    @gregoryhause00 Жыл бұрын

    Thank you for sharing this with us! 😁 I'm sure it wil be very helpful for many people

  • @andrewsimmers8215
    @andrewsimmers8215 Жыл бұрын

    Words can’t describe the brilliance of this video, but I’m leaving a comment to try and help appeal to the algorithm gods, (you guys should too!). You deserve hella love man, thank you.

  • @faiyazibrahim9457
    @faiyazibrahim9457 Жыл бұрын

    The best explanation I've ever seen.

  • @user-ly3fs9jl2p
    @user-ly3fs9jl2p Жыл бұрын

    so much effort for tutorial. great work

  • @redsunpro
    @redsunpro Жыл бұрын

    This video is great. Totally took me out of my dev rut. I was struggling with unity's built in vehicle dynamics. Gonna code this in 🙂

  • @bovineox1111
    @bovineox1111Ай бұрын

    This is a great solution. Love it.

  • @marekhusenica3400
    @marekhusenica3400 Жыл бұрын

    This video is too good to exist :D Helped a ton

  • @bismarckyjag
    @bismarckyjag Жыл бұрын

    Thank you very much for sharing your knowledge!

  • @DovyBL
    @DovyBL11 ай бұрын

    Best car physics video ever! ♥

  • @RoffeDH
    @RoffeDH Жыл бұрын

    This is they type of dev videos I'm looking for right now in my journey. Thank you so much for this! Will recreate what you've said here and put it on my Git project.

  • @jermsbestfriend9296

    @jermsbestfriend9296

    Жыл бұрын

    Bro, if you get a github let me know. I'll contribute requests.

  • @game_developer_7382

    @game_developer_7382

    Жыл бұрын

    Github?

  • @asdfghjkl-jk6mu

    @asdfghjkl-jk6mu

    Жыл бұрын

    github?

  • @rahulcorleone4222
    @rahulcorleone4222 Жыл бұрын

    Great job with explaining, I did not found better than this with example code on the internet. We can find more details about power curves, gears and transmission, air drag, rolling friction, ... , etc for a more accurate simulation on internet, but the foundation is here.

  • @MecegguemMohamed
    @MecegguemMohamed Жыл бұрын

    This is how tutorials should be made explaining the physics and a math behind it in simple way and then dive into coding part, Great Job

  • @ragerungames
    @ragerungames Жыл бұрын

    Thanks!! Finally i achieved the suspension part using hooks law and your guide. Time To make traction better now!!

  • @victorbarreto1067
    @victorbarreto1067 Жыл бұрын

    This is very nice, really! I have been developing a similar game, but there is still a long way to go, but I'm learning a lot while developing. Now I'm in the process of developing the car physics. I was inspired by a very old game from miniclip called "Park a Lot".

  • @ruchirraj5300
    @ruchirraj5300 Жыл бұрын

    Your deep dive videos and blogs have really helped a lot! Thanks for this yet another helpful video ☺️

  • @ruchirraj5300

    @ruchirraj5300

    Жыл бұрын

    Although I'm curious how you made the visualization for the video, like the spring and everything 🤔

  • @ToyfulGames

    @ToyfulGames

    Жыл бұрын

    @@ruchirraj5300 It was all made in Unity in order to make this video! We joke that Unity is our "After Effects" that we actually know how to use.

  • @ruchirraj5300

    @ruchirraj5300

    Жыл бұрын

    @@ToyfulGames I have one more question, for the rotation of tires do you just ignore any case where it could slip(in forward direction), and accordingly, do you just rotate the wheels based on velocity of the car or based on the force applied? 😅

  • @ToyfulGames

    @ToyfulGames

    Жыл бұрын

    @@ruchirraj5300 we look at the movement of the car from the previous frame, and calculate the amount of tire rotation based on the radius of the tires, and accumulate the tire's rotation based on that. if the e-brake is on, we stop rotating the tires so it looks like they lock up.

  • @alexba838

    @alexba838

    Жыл бұрын

    @@ToyfulGames Good afternoon, I have a question. The character has an animation of interaction with the environment, he needs to open the chest. But we can approach the chest from any side, even to the left, even to the right, and the opening animation must be started strictly from one position. How to correctly move the character from the current position to the animation start position? Use inversion kinematics + pathfinding or are there other ways?

  • @PartTimeMonkey
    @PartTimeMonkey Жыл бұрын

    This is an excellent video. Kudos to you.

  • @mrskomps
    @mrskomps7 ай бұрын

    This helps a phenomenal amount, thank you so much for this!

  • @amac333
    @amac33311 ай бұрын

    really enjoyed this, thanks

  • @andersencastaneda6080
    @andersencastaneda6080 Жыл бұрын

    Amazing tutorial, you just get a new subscriber and a new player for very very valet.

  • @celkoken
    @celkoken Жыл бұрын

    Thank you for this!

  • @yogihermawan1181
    @yogihermawan11813 ай бұрын

    Thank you very much for providing such valuable knowledge for FREE! I learned more from your video than any assets I've paid.

  • @geri4367
    @geri4367 Жыл бұрын

    This is so sooo soooooo good. Thank you so much

  • @lionn00b
    @lionn00b11 ай бұрын

    awesome video! really helpful, thank you.

  • @tom_dom
    @tom_dom Жыл бұрын

    Absolutely amazing tutorial! I have 0 knowledge when it comes to Unity and C# coding, but this tutorial has helped me tremendously in understanding how to approach making a custom physics based car in Unity! For me it has helped a lot to ask chatGPT how to implement these functions into Unity which has allowed me to successfully create my own car in Unity now :) Thanks a lot for this extraordinarily well put together tutorial! ❤

  • @xellart
    @xellart8 ай бұрын

    Excellent video!

  • @erikm9768
    @erikm97687 ай бұрын

    Best tutorial on the subject on youtube!

  • @zapoutix
    @zapoutix Жыл бұрын

    Very nice video ! thanks

  • @AndersBergh
    @AndersBergh6 ай бұрын

    Wow. this was amazing. Will def buy the game for me and the kids

  • @yammen
    @yammen Жыл бұрын

    thank you so much this was soooooo helpful

  • @nurdi21
    @nurdi212 ай бұрын

    Great tutorial!

  • @scorpion666lair
    @scorpion666lair Жыл бұрын

    This would have to be one of THE BEST vlogs I've seen. You have articulated what the problem is you are trying to solve, you stepped through in iterations on how to get to a final result, and the video is just polished AF. Well done, I wish to see more just like it!

  • @DougFromTheBayou
    @DougFromTheBayou Жыл бұрын

    Brilliant video! I had come up with a similar raycast solution for my Ludum Dare entry for a scooter game, but I wasnt sure of the best approach for using it on a 4 wheel vehicle

  • @Bardent
    @Bardent Жыл бұрын

    I loved this video!

  • @aliashrafi2063
    @aliashrafi20634 ай бұрын

    19:12 Lost it when I saw the eyes :DDDD. Awesome Guide!!

  • @saiverx
    @saiverx Жыл бұрын

    Such an awesome video

  • @hakanviajando
    @hakanviajando Жыл бұрын

    Amazing video.

  • @PicnicsPete
    @PicnicsPete5 ай бұрын

    This has completely flipped how i'm approuching doing my car physics now. The way you've done the presentation is also amazing, clear, well illustrated and straight to the point. I can't commend you guys enough for this break down and the others you've done. Where can I sign up for your patreon of Unity tips :D

  • @Xorked
    @Xorked5 ай бұрын

    These videos should be used in universities, such great visuals and explanations.

  • @drachenblut_m
    @drachenblut_m7 ай бұрын

    Gonna buy a copy of this game now because this guide is exactly what I needed for the physics of my hover racer lol

  • @tehsimo
    @tehsimo9 ай бұрын

    excellent video!

  • @JohbVb
    @JohbVb Жыл бұрын

    Its a very cool tutorial🤘

  • @billycombo8298
    @billycombo8298 Жыл бұрын

    Pretty sick stuff! Using the raw code won't get you 100% there but it's perfect for the basic premise.

  • @xanderlinhares
    @xanderlinhares Жыл бұрын

    I love these videos so much I bought the game.

  • @EvanLandry
    @EvanLandry Жыл бұрын

    This is so odd, I love it.

  • @teo-1
    @teo-1 Жыл бұрын

    thank you so much

  • @ThwackStudio
    @ThwackStudio Жыл бұрын

    You are mega awesome thanks!!!

  • @3DMVR
    @3DMVR Жыл бұрын

    smart game idea, not really into the diner dash type stuff but driving is fun, and you can mess with ppl, would be cool with flight too

  • @jabnakarramon5121
    @jabnakarramon512110 ай бұрын

    thank you man thank you

  • @danuvip
    @danuvip Жыл бұрын

    Hi, I love your video explanation! Would love to see more videos / tutorials like this! However, I am trying to recreate it for testing purposes and struggle to find the way how you managed the "rayDidHit" variable. I'd appreciate a instrunction :)

  • @ZooHair
    @ZooHair Жыл бұрын

    Just wow 👏

  • @TruckerJoeOfficial
    @TruckerJoeOfficial Жыл бұрын

    Really the best tutorial for car forces I have ever seen! Thank you very much! Anyone has a tip how to get the steering smoothly?

  • @aaronh560
    @aaronh5602 ай бұрын

    This is brilliant. I'm currently fighting with wheel colliders to get the exact semi-realistic arcade-like feel that I want - with predictable controls to be able to increase stats over time without the physics of the car going haywire and it's driving me potty

  • @gamedevquest
    @gamedevquest9 ай бұрын

    you deserve to have your own million sub dev channel

  • @ruka1973
    @ruka1973Ай бұрын

    You could become the new "brackeys". You really have a great talent for tutorials

Келесі