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