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
If we had an award for best car physics tutorial on KZread, this one would be - hands down - the uncontested winner!
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
Жыл бұрын
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
Жыл бұрын
@@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
Жыл бұрын
@@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
Жыл бұрын
@@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
Жыл бұрын
@@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.
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.
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.
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.
Loving these videos. Really nice rigid body controls in unity with explanations are hard to come by. Definitely gonna check out the game.
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.
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.
I didn't expect a tutorial to look this polished! Very informative as well!
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.
You guys are crushing it! These videos have been extremely useful. Thanks for the resources, and thanks for the great game too!
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!
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
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
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!
i think you struck a perfect balance between realism and and simplicity here. amazing job and great presentation too!
This is incredible! Thank you so much for sharing this ingenious car system!
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.
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!
Knowledge and learning is gift that gives joy. Content like this is priceless, it turns my life more enjoyable. Thank your for sharing!
I love the simplicity of it, thanks for sharing this with such quality ! Less rigidbodies is always a win in my book
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!
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!
Such a good series thank you for making these
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.
This is exactly what I was looking for! Very easy to understand and implement.
Perfectly explained basic car physics. Great job, amazing video!
this is absolutely fantastic, thank you so much for making this
These videos are simply amazing. I'm hyped when I see some uploaded. Thank you so much.
Very satisfying and useful video tutorial! Great job!
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!
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!
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!
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!!!
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!
Please make more of these dev-style videos. They are amazing
Great job! Thank you very much for your tutorials!
finally, some one explained clear on Damping. :P Good job Toyful Games!
This was an incredibly good tutorial. Thanks so much for the effort that went into this 🙂
Awesome explanation, looked so compilcated and now it's so simple. Definitely buying the game also as a way to say thank you!
Insante quality tutorial, the content, the visuals everthing is over the top
GOD, What AMAZING TUTORIAL!
thank you so much for this in depth explanation! i love these kinds of videos!
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.
Brilliant breakdown!
Great stuff! Keep going, its very interesting game mechanic.
Thank you for sharing this with us! 😁 I'm sure it wil be very helpful for many people
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.
The best explanation I've ever seen.
so much effort for tutorial. great work
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 🙂
This is a great solution. Love it.
This video is too good to exist :D Helped a ton
Thank you very much for sharing your knowledge!
Best car physics video ever! ♥
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
Жыл бұрын
Bro, if you get a github let me know. I'll contribute requests.
@game_developer_7382
Жыл бұрын
Github?
@asdfghjkl-jk6mu
Жыл бұрын
github?
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.
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
Thanks!! Finally i achieved the suspension part using hooks law and your guide. Time To make traction better now!!
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".
Your deep dive videos and blogs have really helped a lot! Thanks for this yet another helpful video ☺️
@ruchirraj5300
Жыл бұрын
Although I'm curious how you made the visualization for the video, like the spring and everything 🤔
@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
Жыл бұрын
@@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
Жыл бұрын
@@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
Жыл бұрын
@@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?
This is an excellent video. Kudos to you.
This helps a phenomenal amount, thank you so much for this!
really enjoyed this, thanks
Amazing tutorial, you just get a new subscriber and a new player for very very valet.
Thank you for this!
Thank you very much for providing such valuable knowledge for FREE! I learned more from your video than any assets I've paid.
This is so sooo soooooo good. Thank you so much
awesome video! really helpful, thank you.
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! ❤
Excellent video!
Best tutorial on the subject on youtube!
Very nice video ! thanks
Wow. this was amazing. Will def buy the game for me and the kids
thank you so much this was soooooo helpful
Great tutorial!
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!
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
I loved this video!
19:12 Lost it when I saw the eyes :DDDD. Awesome Guide!!
Such an awesome video
Amazing video.
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
These videos should be used in universities, such great visuals and explanations.
Gonna buy a copy of this game now because this guide is exactly what I needed for the physics of my hover racer lol
excellent video!
Its a very cool tutorial🤘
Pretty sick stuff! Using the raw code won't get you 100% there but it's perfect for the basic premise.
I love these videos so much I bought the game.
This is so odd, I love it.
thank you so much
You are mega awesome thanks!!!
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
thank you man thank you
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 :)
Just wow 👏
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?
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
you deserve to have your own million sub dev channel
You could become the new "brackeys". You really have a great talent for tutorials