Racing Game Guide #3 [ My Suspension method And Logic ]

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

I think ig suggested tour account to me

👍︎︎ 1 👤︎︎ u/YTItzyaboisifou05-bs 📅︎︎ Dec 14 2020 🗫︎ replies
Captions
[Music] hello guys welcome to the third episode of racing game guide if you haven't watched previous episodes please watch them in this video i will show you my method of making suspension for vehicles in unity by the way guys the raycast method i talked about in my previous video is more dynamic than my method you can make a realistic vehicle controller with that if you want but my method is good for arcade style racing so let's start first you need a 3d model of a vehicle you can get some free models from unity asset store or make your own but make sure your model has the body and wheels mesh separated and the wheel mesh's pivot should be in the center if your model comes with a body and a single wheel mesh then just duplicate it and place it in the four quarters i am using this model that i bought from unity asset store i would recommend you to keep an eye on the asset store whenever a deal comes because i got 20 high quality assets just for 35 plus 7 tax of course but it was a very good deal by the way this asset that i am using is tuned racing and it does not include logic just 3d models so i am using this model for demonstration i will quickly separate the body and wheels so we have a body and four wheels separated we will add rigid body components to all four wheels and the body two and set the body mass to fifteen hundred and wheels mass to twenty values may defer for your model try using real life values then we will add sphere colliders to wheels and adjust its radius then add a configurable joint component to all four wheels and drag and drop body to the connected body slot then set the anchor position to zero zero zero let's see what happens i forgot to add a collider to the body add a box collider to the body and adjust its shape then select all four wheels and in the configurable joints section lock every motion except ymotion then hit the play button now select all wheels in play mode and go to the configurable joints section again and open white drive and set the position damper to something like 10 or 20 and keep increasing position spring until the vehicle body moves up for my setup the spring value was 100 000. just play with these values and find out what works for you and remember whatever changes we made in play mode will not be saved so remember the values and place those values in white drive in edit mode then hit the play button and you will get a really nice bouncy suspension now you will have some issues with the wheels when you try to implement acceleration and turning because of friction so i would recommend making a physics material with zero friction and adding it to wheels and the ground this will make your vehicle slippery but you can make a friction logic in your script so this was a demonstration of my method for suspension i will show you a comparison between raycast based suspension and configurable joint base suspension later in this video now i will talk about vehicle movement logic for arcade games what we will do is whenever the acceleration button is pressed we will add a forward force to the body and if the break button is pressed we will add a backward force to the body if you add this force to a slightly lower position than the body's center of mass you will get this accelerating and breaking motion just like a real vehicle let's see why is that if you add a force to an object and the force direction passes through the center of mass the object will accelerate in that direction but if the force direction does not pass through the center of mass then that force creates a torque and the object will move plus rotate and in case of our vehicle the suspension spring force will take care of not letting the vehicle to roll or flip of course if you increase the force so much then the spring force can't handle it so make sure to use reasonable values now for turning we will add torque on the body depending on the input direction guys if you are using rigid bodies then you have to use forces and torques for movements because if you just rotate the body each frame and translate the body forward each frame you will get some glitches so use force and torque now you have movements but your vehicle is sliding because there is no friction to fix this we will find the vehicle's velocity vector and calculate the sideways component of velocity and we will add a force in the opposite direction of the vehicle's sideways component the amount of force depends on your choice whether you want your vehicle to drift or crew less force means more drift and more force means more grip so this is the basic logic of vehicle physics in arcade games now it depends on you if you want to add some other mechanisms on top of this you can add flying mechanism you can add jumping and more now i will show you a comparison between raycast-based vehicle physics and configurable joint based vehicle physics of some upcoming games i will link social accounts of those game developers in the description if you like to check them out so the first game is pocket wheels by florian wolfe in this game he used a raycast-based approach and he implemented some extra features such as flying flipping vehicles and grappling this game looks so nice and fun and the level design idea is very cool riding car indoor on a foosball table very cool feeling next game is zekist by yannick church he also used a raycast based approach this game's visuals are so eye-catching and with the low-poly look and good use of color theory this game really stands out and funny characters and dracula deaths makes this game more engaging now i will show you my game with configurable joints approach i haven't added any extra features just drifting and auto balancing auto balancing is very easy you just have to check whether the vehicle is grounded or not and if the vehicle is grounded you keep the center of mass of the vehicle to center of the vehicle's body and if the vehicle is not grounded you change the center of mass position to slightly beneath the vehicle's position this makes your vehicle to always roll back upright i figured out three types of vehicle behavior with my vehicle physics rally cars formula one car monster trucks i am also working on an asset for this type of vehicle physics it's almost done i just have to add some particle systems so this was a comparison between two methods i would recommend configurable joints method for arcade games as it's very easy to implement and raycast method for more advanced or realistic physics but you have to learn about how vehicles work in the real world i am also learning about it and i will make a video on it later in this series at the end if this video was helpful for you give this video a like subscribe to the channel if you want to see more videos like this if you have some questions or suggestions comment down till then keep learning stay motivated and keep making games [Laughter] goodbye
Info
Channel: Ash Dev
Views: 5,609
Rating: undefined out of 5
Keywords: #unity3d, #gamedevelopment, #indiegamedev, #drift, #rallygame, #racing, #madewithunity, #guide, #formulaone, #monstertruck
Id: hbM183WaYl4
Channel Id: undefined
Length: 6min 28sec (388 seconds)
Published: Mon Dec 14 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.