For those attempting to convert this project to Godot 4, the conversion will only get you so far. The scaling of the track and the paths will be off (the paths are far bigger than the track), the car position in the world will need adjusting and a few key functions have been renamed: "update()" is now "queue_redraw()" "offset" is now "progress" (you'll know where to replace these when you try to run it) Export syntax has also changed: @export (bool) var show_debug = false becomes @export var show_debug : bool = false etc Hope this helps! A great little project - thanks KidsCanCode. (it would be nice to see this officially updated for 4.0 as part of your new series)
@Kidscancode Жыл бұрын
Or you can look at the updated version: kidscancode.org/godot_recipes/4.x/3d/3d_sphere_car/
@retroleigh Жыл бұрын
@@Kidscancode Perfect! Didn’t even see that when I looked at your site. When did you add that?
@akitaropiquet75803 ай бұрын
@@Kidscancode No offense but the updated script for 4.x doesn't work. Either I'm missing something obvious or the tree is messed up. The root node is RigidBody so the mesh follows the movement of the sphere.
@akitaropiquet75803 ай бұрын
I must be missing sth obvious, bc I downloaded your project for 4.x and it works great! With the same code & tree on my own, the mesh is rolling with the ball (and so the "car" stops moving forward soon after).
@akitaropiquet75803 ай бұрын
I think I found it: on your website, you forget to mention to activate "Top Level" in CarMesh Transform.
@steve163843 жыл бұрын
This is the first Godot vehicle game I've come across where the vehicle handling is both accurate and fun. Edit: And I've just discovered there's an AI car as well. Even better!
@atlantisfigi7583 Жыл бұрын
Where did you find AI car?
@steve16384 Жыл бұрын
@@atlantisfigi7583 Sorry, it's been a while so I can't remember. I assume it was somewhere in the source.
@humoroushusky86293 жыл бұрын
You explains things very well! Great job! 👍🏻
@MP-pv4ebКүн бұрын
Thank you, good tutorial. I do want to point out that I initially tried to follow the text tutorial on your site, but I ran into a few issues. Turns out for things to function correctly, the car mesh needs to have transform>top level checked.
@Josematube2 жыл бұрын
Very very original the approach of using a RigidBody for handling the car. Thanks for the tip! Regards. Jose.
@memeplus7560Ай бұрын
This might just have given me a very VERY specific piece of the puzzle that I have been posed with for a while. This might also be how the Asphalt franchise has handled it’s vehicle movement. This didn’t just help me it saved me a LOT of work.
@skaruts3 жыл бұрын
You might want to invert the mesh rotation when you're reversing, or else it will look wrong: _if ball.linear_velocity.length() > turn_stop_limit:_ *var rotation_dir = rotate_input if speed_input >= 0 else -rotate_input* _var new_basis = car_mesh.global_transform.basis.rotated(car_mesh.global_transform.basis.y,_ *rotation_dir)*
@Luchs0103 жыл бұрын
But with this solution, the car only correctly rotates while you are holding back, if you let go of the key, it will start rotating in the wrong direction again, but it's still driving backwards until it stops because of friction
@skaruts2 жыл бұрын
@@Luchs010 perhaps that's true, I can't remember. But I used something in another project that might help: I used a *move_direction* variable to track whether the car was going forward or backward, and I set it like this (in _process): *move_direction = sign( car.linear_velocity.normalized().dot(-car.transform.basis.z) )* Iirc, that will set *move_direction* to -1 or 1, depending on which way the car is going. When *move_direction* is *-1* you invert the steering. In this case the "car" is also a RigidBody, but it's not a sphere. So, I'm hoping it works with the sphere too, but I haven't tested it. Sorry for replying so late.
@MeanGeneHacks3 жыл бұрын
Best channel on Godot by far!
@thelumberjack88383 жыл бұрын
Amazing video as always
@DenerWitt3 жыл бұрын
god damn it, I really needed this first 1 minute. This is a great way to make a car game. I feel like I just met Jesus.
@Kidscancode3 жыл бұрын
It really is a cool method. When I saw the original Kenney tweet about it, I knew I had to try it in Godot.
@emmadrew503 жыл бұрын
i have met Jesus and i can confirm he is a cell shaded car
@cinomontague3 жыл бұрын
Keep it up I love seeing new Godot content
@mathew3267Ай бұрын
I did this same thing in Unity. Its fine for driving on 100% flat surfaces.
@jaffnimanlangit55103 жыл бұрын
been long time u not upload anyway thanks for the upload and tutorial aprreciate it mate quick question will u make another tutorial for mobile in the future?
@Kidscancode3 жыл бұрын
What about mobile? Most things are platform-independent.
@minadaniel8142 жыл бұрын
Why wouldn't you make a full Godot course? It would be great, and I will definitely enroll on that one.
@swangames44502 жыл бұрын
he has a website with loads of great text tutorials!
@FrozenWell3 жыл бұрын
great tutorial just starting to look at 3d in godot so super useful
@VojtechLacina3 жыл бұрын
This is great tutorial, I got huge inspiration from your car tutors in the past. I'd like to ask - do You create the track in other app like Blender or do You use Godot spline tools? I tried to use them and I'm finding them very unintuitive to work with - manualy setting locations of points of "the road" is very frustrating
@Kidscancode3 жыл бұрын
No, I made the track in Blender using the art pack that's linked in the writeup. Agreed, the 3D pathing tools need some improvement.
@VojtechLacina3 жыл бұрын
@@Kidscancode Thank You
@dmr12jmy2 жыл бұрын
Great video. Any pointer on how to use Blender with the art pack to create the track? I hacked a script together to import all the obj files and spread all the objects in Blender so I can clearly see then and select them. Snaping to grid, I can sortof put something together, but that's hard. At least much much harder than it looks with the tool MAST, created by the author of the art pack (but for Unity though).
@CosimoDavideViggiano Жыл бұрын
I agree with you, and the big issues is: how to set the mesh collider? I had problems with the tutorial, I tried to create my simple track with the same asset, but when it comes to set the collider...how I can do? From Blender? From Godot? I have tried to create the mesh collider in Godot, but my car as a strange behaviour. So I don't know if it was my fault at code or my fault to make the track.
@darshigoswami51243 жыл бұрын
Can u teach us how multiplayer mode works for godot and also a tutorial on making a drag and drop inventory system???? Ur tutorials have been so helpful.
@Kidscancode3 жыл бұрын
I have multiplayer on my list, just haven't gotten to it yet.
@gear3232 жыл бұрын
Hopefully someone eventually does a remake of Atari Hard Drivin' or better yet, Atari Race Drivin' in Godot. That would be super awesome. After all, that was the first 3d driving game ever made for the arcades. The Grand Daddy of the entire genre
@koosh43193 жыл бұрын
Could you make a tutorial on creating a multiplayer simple racing game?
@jlebrech2 жыл бұрын
what about a hybrid approach, the standard way to control a car but also this way to simulate drifting?
@bioman1hazard607 Жыл бұрын
Omg I'm gonna make a fun game with this, thank you
@Oreboat Жыл бұрын
overall this still works in godot 4 but when I try to rotate to a mesh normal or have the mesh lean while turning it can be a but glitchy for rotating the mesh to another mesh's normals it just doesn't allow turning, at all, sideways or to another mesh for rotating to lean during a turn it overall works but the mesh keeps trying to correct itself back to facing forward
@Wonkabonka Жыл бұрын
sad to hear that since i was gonna try making this
@ZeldaACFan174 ай бұрын
I wonder if you could rotate the model on an axis in the direction you turn to simulate leaning on a motorcycle, or rotate on the same axis but in the opposite direction of the turn to simulate body roll in cars 🤔 Maybe have the lean angle increase up to a point with speed for a bit more realistic looks
@cholasimmons Жыл бұрын
i love your rendering style, is that a form of toon shader?
@Kidscancode Жыл бұрын
It was an outline shader I grabbed from somewhere.
@1MoreSonicRobotАй бұрын
I noticed that as the collision ball is rolling it bounces a bit. Wondering if locking the rotation on the collision will provide a much smoother movement?
@marcosadrian653 жыл бұрын
Simply the best! Awesome tuts please do more 2d stuff!
@Kidscancode3 жыл бұрын
Hah, usually people are asking for more 3D content. What would you like to see in 2D?
@marcosadrian653 жыл бұрын
@@Kidscancode thanks! we'll hope not be a super complex theme but will be interesting see how we can build a rope system, that can interacting whit kinematicbody2d for instance, but it's just a suggestion I think that anything you want to show it's more than fine 😀
@cmds.learning74263 жыл бұрын
cool project
@rlplayz66433 жыл бұрын
only request is maybe show how to make a drift/skid clouds as you have in the demo
@fcole903 жыл бұрын
Thanks for the great tutorial! 😃 Unfortunately, when I open my model it doesn't display its subtree. I can only press on the editor icon and then it tells me if I want to create a new inherited scene. Did you use some special settings to achieve that? I'm using version 3.2.3.stable.mono
@mimes44943 жыл бұрын
maybe the editable children tab? you select the node and right click on it there should be that option
@bruceparker6142 Жыл бұрын
I'm using godot 4 for this tutorial. I noticed your line onready var car_mesh = $CarMesh But there is no CarMesh node in your scene tree. How did that work? I used @onready var car_mesh = $sedan because the car I chose was a sedan and I just copied the node path. If I typed CarMesh the error suggests the node does not exist my CAR is: Node3d Rigid Body (Ball) collisionshape (sphere) Spatial (sedan) #this is how it was imported from Kenney spatial (sedan2) meshinstance (body) meshinstance (wheel_backLeft) meshinstance (wheel_backRight) meshinstance (wheel_frontLeft) meshinstance (wheel_frontRight) RayCast3D DirectionalLight3D Camera3D My WORLD consists of a Node3d- staticbody3d collisionshape3d #box meshinstance #plane directionallight3d camera3d When I run the scene I get no script errors but my car will not move. I tried to redo the car using simple shapes from godot instead of importing Kenney's car Node3d Rigid Body (Ball) Collisionshape3d (sphere) Node3d (car) meshinstance (body) #box meshinstance (wheel_backLeft) #cylinder meshinstance (wheel_backRight) #cylinder meshinstance (wheel_frontLeft) #cylinder meshinstance (wheel_frontRight) #cylinder RayCast3d My world to put this new car in is the same as before. Now my car falls through the ground. So I did the following: Node3d Rigid Body (Ball) Collisionshape3d (sphere) RigidBody (car) meshinstance (body) meshinstance (wheel_backLeft) meshinstance (wheel_backRight) meshinstance (wheel_frontLeft) meshinstance (wheel_frontRight) RayCast3d CollisionShape3d #to collide with the ground of my world This stopped the car from falling through the ground but now it bounces non stop. Can anyone assist? I added collision shapes to the wheels and adjusted the location of my collision shape for the ground and that stopped the bouncing. I'm using a rigid body for the car. The wheels rotate when I steer but the car skates around as though it's driving on ice.
@ChipmunkiousD Жыл бұрын
3.5.1, car isn't moving. I wouldn't think it'd make a difference since the sphere is doing the heavy lifting, but does the fact that I'm trying to use a Sprite3D instead of a mesh have something to do with it? Or maybe it's something with my track (simple flattened cylinder with a collider)?
@TheInfamousLegend27 Жыл бұрын
i would've suggested putting the sprite as a child of a spatial node, but using the spatial node instead of the mesh itself doesn't let it move so idk. I do want to figure this out myself tho because the option of a 3D and 2D billboard racer mode is something I want to toy with
@danielkeenan25083 жыл бұрын
Very nice. Thank you.
@pascalcasier9593 жыл бұрын
Excellent
@rbcubosengenharia6943 жыл бұрын
This is awesome, thanks. I have some trouble with my car bumping, solve using lerp in car_mesh.transform.origin = ball.transform.origin
@Kidscancode3 жыл бұрын
Yes, I had that as well. It's an issue with rigid bodies and collision meshes. I solved it the same way. :)
@dagnolio60133 жыл бұрын
@@Kidscancode How did you guys go about this exactly? I have tinkered with lerp but it does not seem to solve the bouncing with the track
@Kidscancode3 жыл бұрын
@@dagnolio6013 I lerped the y position of the model, so that the small changes in the sphere bumping up and down are smoothed out.
@drdrub3 жыл бұрын
@@Kidscancode I've been trying to troubleshoot this. It appears the issue starts when the gravity is changed from 1 to 10. Feels like there should be a better solution.
@rlplayz66433 жыл бұрын
what would be the code for this? i have been experimenting with lerp and I understand it but not sure what to call inside it
@pizzarand8 ай бұрын
Didn't look that great in my project (when interacting with slopes) but thanks for the excellent tutorial nonetheless.
@triq0 Жыл бұрын
love this tutorial but i'm not really familiar with managing scenes in godot. i made a new test scene and tried dragging in my car scene that had this tutorial and now my car isn't affected by gravity and doesn't do anything
@NateHeroic3 жыл бұрын
This is awesome.
@willbrownmusic Жыл бұрын
Does not work anymore, get an "(update)" error, not found in base self
@Kidscancode Жыл бұрын
There's nothing stopping this from still working. You'll have to account for Godot 4 changes, but those are documented well. That said, your error message is incomplete - that's not exactly what it says, and you've provided no context, so it's impossible to say what the actual problem with your code is.
@retroleigh Жыл бұрын
The update() method in the "Control" node has been renamed to queue_redraw() in Godot 4+
@33339275 ай бұрын
No dump in speed with "ball.add_constant_central_force()"
@thelumberjack88383 ай бұрын
use the apply_central_force
@deviouschimp4663 Жыл бұрын
Wait, with this approach. If you are turning while no longer accelerated, turning wouldn't work no?
@DestusG3 жыл бұрын
We need more recipes😁
@Kidscancode3 жыл бұрын
Suggestions?
@DestusG3 жыл бұрын
@@Kidscancode shaders?
@bioman1hazard6073 ай бұрын
So I've found an updated version of this tutorial but when I try to add my own vehicle model, the game breaks, is there any way you can update this tutorial to 4 and make it modifiable
@ruslanakhmadov5870 Жыл бұрын
Thank you! Any tips how to add an extra collision for a car (sphere doesnt cover the full mesh and car goes through wall halfway) ? Anything I tried ended up with walls ignoring extra collision or it rotates with a sphere
@TheInfamousLegend27 Жыл бұрын
increase the radius of the original collision shape to a precise size maybe? just a quick idea lol
@TheWilsonChannel3 жыл бұрын
Hey, I'm kinda stuck with a weird issue, been following up to 10:00 and while the car moves forwards and backwards if I give it inputs as soon as the game opens, if I don't give an input during the first second or so the car seems to be locked/asleep, checked with some debug labels and Godot seems to still be responding (the labels update when keys are pressed and shows their names). Also tried downloading the repo, and grabbing the CarExample scene, model and script into my project and it also has the same issue. Debugger doesn't seem show any issues. Thanks for the tutorials! Really like the explanations
@TheWilsonChannel3 жыл бұрын
So, setting the Ball's gravity scale to 10 (originally left it at 1) and activating Can Sleep seems to have fixed it.... that's my fault I guess for trying to play around with parameters before even checking if it was working
@w.lf404 Жыл бұрын
how would you activate the particle emission when the car drifts? in your written tutorial there is nothing, just add particles :D
@itsME-dc4vm3 жыл бұрын
Nice ;D
@HavingFunTimes Жыл бұрын
how do you stop the sphere bouncing?? 0:27 you can see it bouncing so much, it makes it really jittery
@Kidscancode Жыл бұрын
This is coming from the trimesh collision of the ground. It's easily solved by lerping the y position of the model.
@HavingFunTimes Жыл бұрын
@@Kidscancode thanks for the response! mine ends up bouncing so much that it comes off the track! I guess Ill have to find another method like raycasting.
@n41sd3 жыл бұрын
Nice idea, theres any possibility to limit on a path the track and avoid car to turn and go to wrong way? I`m coding a old school car game and i need to limit to go only foward! Thanks
@Kidscancode3 жыл бұрын
Definitely - that's how the AI cars are driving around the track. You have a Path that follows the track and that allows you to determine if you're pointed in the right direction. Similar to the example I did here: kidscancode.org/godot_recipes/ai/context_map/
@chimingito3 жыл бұрын
is it possible to have the sphere only collide with the ground but have a different hitbox that's more accurate to the car mesh be used for hitting walls and other cars?
@Kidscancode3 жыл бұрын
Definitely. I'd put it on a separate layer so the car bodies collide with each other.
@chimingito3 жыл бұрын
@@Kidscancode hm I cant get it to work, since the car mesh is not parented but being placed at the pivot of the sphere with code, I can't find a way to make the forces from the collisions transfer from the car collider to the sphere.
@bnkm072 жыл бұрын
can u make a tutorial that start a timer after the game starts and when u reach the finish line it stops and save the time as highscore?
@РашидБерезкин3 жыл бұрын
How this type of car behave on slopes / ramps? What happened if it stops on ramp? Will it roll back due to gravity?
@Kidscancode3 жыл бұрын
It works fine on ramps (example shown in video). Whether it rolls back depends on your angular damp setting.
@GostosasGarotas3 жыл бұрын
wow!
@OkamiSatsugaiCheri4 ай бұрын
For some reason I can't open the 4.X version of the project. I am using Godot 4.1.3.
@LennoxKnight-st6lm4 ай бұрын
could you do an arcade racer video for 4.2 or (by the time this comment is made) 4.3?
@msrsls59833 жыл бұрын
真棒👍
@DRSChickenYT Жыл бұрын
do you have a tutorial on how to make the race track?
@lordnaeo46703 жыл бұрын
Hi...sorry for my question, but do you know how to integrate the steam SDK with godot? I already used the "godotsteam". I compiled everything correctly and the godot even opens. The problem occurs when I use debug. It doesn't open anything ... I tried several times. If you can help, thank you (sorry for English. I'm using google translator).
@jasperbrooks21183 жыл бұрын
can you make a ' capsule ', that can only roll forward and, pivot . .
@Kidscancode3 жыл бұрын
I'm not sure what you mean. The "tilt" is something we added manually, the model doesn't tilt on its own.
@badmonkey91 Жыл бұрын
why is it if I delete the lines of code "if not ground_ray.is_colliding(): return" it breaks the whole thing? I want to be able to turn in air
@TheInfamousLegend27 Жыл бұрын
i think you could try removing "return" and instead putting "speed_input = 0", so your speed cant increase, but the rotation can still be used. lmk if it works :)
@cbaptou Жыл бұрын
How would I limit the max_speed of the car
@yourkodi3945 Жыл бұрын
might of missed it but how did you make the rroad?
@mrdinoking66263 жыл бұрын
Sir I got a problem here , the car doesn't move when I press the appropriate keys (I have done the necessary in input maps in project settings), and I have the exact same script and scene hierarchy as yours . Just the track is different (a simple cube from Godot itself in main scene), what do I do?
@skaruts3 жыл бұрын
Make sure the RayCast position is a little bit above the floor. If the starting point of the raycast is inside the ground it won't detect the ground, and the *"if not ground_ray.is_colliding()"* check will always be true and prevent you from moving. I had this issue myself. If this isn't the problem you're having, then I don't know what could be.
@slimabob3 жыл бұрын
@@skaruts I was having the same issue and this helped. Thanks!
@StephenCathcart Жыл бұрын
I'm not sure if it's a Godot 4 feature but you can also tick the Hit From Inside checkbox on the RayCast3D to prevent this, had the same issue :).
@thelumberjack88383 жыл бұрын
The car pops up when I import a track from blender, how do I fix this?
@nanoic2964 Жыл бұрын
I'm getting a Attempt to call function 'add_exception' in base 'null instance' on a null instance. error.
@Kidscancode Жыл бұрын
A "null instance" is what you get when you `get_node()` an invalid path. It means the thing you're calling `add_exception()` on is invalid.
@Inferryu3 жыл бұрын
How do I properly attach your camera? the parent node doesn't inherit the location so if I put the 'car' scene as a target for the camera it doesn't follow the car because technically the node is not moving from where it is.
@IPunchWithMyFists2 жыл бұрын
I have the same question. It's driving me mad. Great tutorials by the way!
@Inferryu2 жыл бұрын
@@IPunchWithMyFists I solved it by going into the car scene and add it as a child of the scene and then set the car mesh as the target, it works but it still feels wrong.
@IPunchWithMyFists2 жыл бұрын
@@Inferryu agreed. I tried that myself. Strange. Thank you for the help regardless!
@TheInfamousLegend27 Жыл бұрын
@@IPunchWithMyFists the best way to do it is to add a spatial node as a camera pivot, make the camera a child and in code lerp the movement of the spatial pivot node on the axis so instead of snapping to the car, it smoothly moves to the car's new position. hope this helped a lil :)
@JayGames-n5t10 ай бұрын
How to make the camera please
@vishalrajrai38662 жыл бұрын
Can we make enemy which chaise us in Godot game
@IceRl1-v8d3 жыл бұрын
how can i make it with keyboard controls
@Killer-ve5ms Жыл бұрын
how to add the car to the map?
@IceRl1-v8d3 жыл бұрын
pls could you do keyboard controls tutorial?
@Kidscancode3 жыл бұрын
This has keyboard controls.
@IceRl1-v8d3 жыл бұрын
@@Kidscancode thanks man!
@bangtanscouts73913 жыл бұрын
Please give me link of pygame and godot links which you have or made a video of pygame and godot download please!!!
@Kidscancode3 жыл бұрын
There are links in the descriptions of each of my videos.
@biraj8008 Жыл бұрын
does anyone know how to add skid marks to it while its drifting
Can you make Car Arcade Ai Style. Please Please please
@deutandev17283 жыл бұрын
How to make that cartoon-ish style in 3D?
@Kidscancode3 жыл бұрын
The written version (linked in the description) has a link to the outline shader I'm using.
@MicrowaveNoodles Жыл бұрын
can it go uphill?
@Kidscancode Жыл бұрын
Sure
@MicrowaveNoodles Жыл бұрын
@@Kidscancode please excuse me for being a bit ignorant, i didnt pay attention to most of the video
@vitorgabrielgomesrodrigues Жыл бұрын
You didn't link the tutorial
@gregorydunks2 жыл бұрын
I did the first steps and my car is just bouncing up and down
@tato64182 жыл бұрын
How do you manage the camera here?
@Kidscancode2 жыл бұрын
It's a chase camera like this: kidscancode.org/godot_recipes/3d/interpolated_camera/
@GoticaArcana3 жыл бұрын
Is better this approch or the other you have done kzbin.info/www/bejne/jZnahH6vfM-Ep5I ? What are the differences between the two?
@Kidscancode3 жыл бұрын
There are as many approaches to cars as there are car games. In this example, we have a very simplistic rigid body model, while the other you linked uses kinematic physics.
@GoticaArcana3 жыл бұрын
@@Kidscancode For an Arcade racing game is this better?
@TheInfamousLegend27 Жыл бұрын
@@GoticaArcana depends what you want to do really. i'd say experiment with this RigidBody example, the Kinematic example and the VehicleBody approach. all offer different things :)
@vapanait Жыл бұрын
I don't get it. You added a reference to CarMesh but there is no CarMesh node.
@sudome59073 жыл бұрын
His voice is very much like 'Jim Browning's (He is a scam baiter, if you live under a rock)