Man, I was trying to use NavMesh for the whole thing and pulling my hair out. I make things too hard for myself sometimes. Thank you for steering me back on track!
Thank you for the tutorial, in Unity 2020.2.2f1, my car was experiencing an issue whereby the car would be steering and not going straight to the point. I fixed with this: if (AngleToDir == 0 || (AngleToDir < 10 && AngleToDir > -10)) { TurningAmount = 0; } I gave the car a range between 10 and -10, and if it is in between the range, it should not steer, also if the AngleToDir is 0, then it shouldn't steer. Hope this helps!
I was experiencing the same issue, and was expecting that I might have to make the car "less sensitive" to the angle - this solution worked perfectly, so thanks a lot! :)
One small suggestion is to change turning to an inverseLerped value of angleToDir. Otherwise it will be constantly be making full corrections to the left or right, which will slow the vehicle to a halt if you're using wheel colliders with sideways friction.
Thanks Code Monkey!! This is so much better and more customizable than ML. Forget ML and make your own. I very much needed the how to steer part. I wasn't able to get it. Thanks Code Monkey for helping me complete racing project :)
Great tutorial, this was literally exactly what I was looking for! Perfect for simple racing enemies :D My only comment would be that I had a minor issue with the car turning left/right all the time and never going completely straight (sort of zig-zagging towards the target). Chidebe Nosiri pointed out a solution that seems to work for that, by simply making the car less sensitive to the angles. Once again, great video!
Instead of an input 1f you can create a dynamic input by divindng the angleToDir/70f so depending on how sharp the angle is it turns more or less wich looks smoother
Uh? Adding support for elevation needs to be added to your Driver script, not the AI script which is what this video is about. The AI doesn't care if the target is above or below, it just goes forward, left and right. As long as your Driver script supports elevation this AI will get there.
Great video man, the tutorial is really awesome. By the way can you make some tutorials on procedural animation. There are not much tutorial about this topic in the internet.
Can I ask about the PC requirements to run such learning simulations? How long such example could take? Is there a way to benchmark mark and understand what type of hardware I need specifically for AI simulations? Like Processor, Ram and GPU? Appreciate your great and wonderful contents ☺️☺️
Please help. For some reason my angleToDir calculation keeps oscillating very quickly between the same angle of a positive and negative value. I have debugged all the parameters within the equation and I still cannot figure out why this is happening...
Instead of doing a Vector.distance couldn't you use the dirToMovePosition sqrMagnitude or magnitude before normalizing? Would this be better or equivalent in performance? Thanks for the awesome video.
Hello Code Monkey! I have a question for you, i thank you so much for this tutorial i learn to make something similar, but when my car is following the target, the car start to shake like if his turnAmount was to -1 to 1 to -1 to 1 everytime , you know how i can solve this?
CarAi works strangely for me with blender models, they start to move sideways, there were also problems with scripts, but I fixed them. Can anyone please help? Is there another AI similar to this that is capable of avoiding obstacles for cars? I need for my rts.
💬 Let's build a Simple Car Driver AI Great for any Driving or Racing Game where you want a Car to go to a certain position I used this when making my Racing RTS ua-cam.com/video/mNoyPz3LCy0/v-deo.html
@@CodeMonkeyUnity Thx but when I search something like "Unity tutorial for beginners" then your playlist comes up which has more videos like more than 30 or something like that. Okay, no problem! You would have some issues with that playlist I guess.
Though nice, I really do start to feel that the term AI (or Artificial Intelligence) is starting to lose its meaning. I guess that's always the case though in the context of showcasing some "basics". Weird though that we now start to consider ML to be what AI stands for :D
You give it a target point and the car figures out what actions to take to get there, that's Artificial Intelligence, a non-intelligent entity couldn't figure that out The issue is that AI has become a buzzword that some people use in a much more limited way than the words actually mean. This is Classic AI, I've also made a Car Driver using Machine Learning AI ua-cam.com/video/2X5m_nDBvS4/v-deo.html
@@CodeMonkeyUnity I guess what I was trying to say is: AI seems more automation than intelligence. Sure, there may be some wheight-based and/or priority based decision making along the way. Perhaps even complimented with some prng in there, but given the same parameters it will always behave the same way. It's a great way to approximate the appearance of intelligence. In that sense, I fully agree: It has become a buzzword. It was the best we could do at the time we started giving NPCs behaviours, but is it still accurate to call it AI, now that we have ML I wonder? MachineLearning, within the confines of its rules, can/will evolve and change its behavior over time. To me, that's much more "intelligent" than what we attribute to AI. What we call AI, is more a reflection of how much effort was put into the development of the behavioural rules of "automation". Anywho, I very much love your videos and my comment was not meant as a critique of the content. I was merely posting a thought that's been going through my head. I apologize if it came across as such.
im trying to make this in 2D, and the car will just keep going backwards no matter where i place the target, is there a fix? edit: looks like it works on the z axis, ill see if i can solve it edit 2: ill leave this comment here for who does it in 2D, just change the forward in dot to up and it should work
Maybe your mailer rejected a newsletter or reported it as spam, when that happens the email gets unvalidated to prevent it from sending emails to people who dont want them. Try adding contact@unitycodemonkey.com to your whitelist and request another validation
Can someone help me? I used to play a game in my phone 5-6 years back. It was a roller coaster game with different levels. In levels some tracks are missing, some tracks fall when you pass of them and there are passengers who fall it you ride carelessly. If you know such a game, please tell me.
It's included in the project files linked in the description. It basically just moves the car along the transform.forward and rotates that game object, it's pretty simple
Does anyone know How I can try make game similar to Fire Emblem, I would like to try make a game with tose same machanics bit I don't know where to start. Dice I'm New to programming
That's a pretty complex thing to do if you're new to programming, I covered a Grid Based Turn Battle System here ua-cam.com/video/mONHucoYASU/v-deo.html ua-cam.com/video/0QU0yV0CYT4/v-deo.html
@@CodeMonkeyUnity Thanks brother, now I'm going to watch the videos to see if I get it, another question, do you know how I can make a button in the same action menu, that is, attack, special abilities, etc., that simply appears when my character has little life to transform?
@@lee1davis1 hard coding = setting variables at runtime. for example the forwardAmount in the Update function. no hard coding would be referencing them outside of functions and then use the reference.
#CodeMonkey estou usando unity 2022.2.6 e da erro Assets\CarDriverAI\Scripts\CarAITargetMouse.cs(13,40): error CS0103: The name 'Mouse3D' does not exist in the current context e Assets\CarDriverAI\Scripts\CarDriver.cs(100,43): error CS0103: The name 'GameHandler' does not exist in the current context criei private Mouse3D; e esses erros acima some e aparece outro Assets\CarDriverAI\Scripts\CarAITargetMouse.cs(10,20): error CS1519: Invalid token ';' in class, record, struct, or interface member declaration como resolver isso,por favor ajude-me.
🌐 Have you found the videos Helpful and Valuable?
❤️ Get my Courses unitycodemonkey.com/courses or Support on Patreon www.patreon.com/unitycodemonkey
@@user-de9gl3qw6f use bolt in unity
I love AI stuff! I also do a lot of AI things in unity lately i work with procedural generation and AI its so much fun! 👍👍
Brilliant as usual! I’ve been working on a space ship AI for our game using pid controllers and raycasts and it’s pretty fun!! 😀
Nice! I hope your development is going well!
Man, I was trying to use NavMesh for the whole thing and pulling my hair out. I make things too hard for myself sometimes. Thank you for steering me back on track!
Thank you for the tutorial, in Unity 2020.2.2f1, my car was experiencing an issue whereby the car would be steering and not going straight to the point. I fixed with this:
if (AngleToDir == 0 || (AngleToDir < 10 && AngleToDir > -10))
{
TurningAmount = 0;
}
I gave the car a range between 10 and -10, and if it is in between the range, it should not steer, also if the AngleToDir is 0, then it shouldn't steer. Hope this helps!
I was experiencing the same issue, and was expecting that I might have to make the car "less sensitive" to the angle - this solution worked perfectly, so thanks a lot! :)
I'm loving the great variety of content on your channel! 😀
Adddd to my unity must watch playlist. A lot of great logic here thanks
you can multiply speed by dot product so they will make sharper turns
Oh that's interesting, didn't think to use that one
That's awesome!
One small suggestion is to change turning to an inverseLerped value of angleToDir. Otherwise it will be constantly be making full corrections to the left or right, which will slow the vehicle to a halt if you're using wheel colliders with sideways friction.
Who remembers Carmaggedon?
Awesome game! I definitely remember playing it as a kid, it was one of those "forbidden" games, kind of like GTA
@@CodeMonkeyUnity I played the pixelated version, and back then was amazed with the graphics 😆
Thanks Code Monkey!! This is so much better and more customizable than ML. Forget ML and make your own. I very much needed the how to steer part. I wasn't able to get it. Thanks Code Monkey for helping me complete racing project :)
Great tutorial, this was literally exactly what I was looking for! Perfect for simple racing enemies :D My only comment would be that I had a minor issue with the car turning left/right all the time and never going completely straight (sort of zig-zagging towards the target). Chidebe Nosiri pointed out a solution that seems to work for that, by simply making the car less sensitive to the angles. Once again, great video!
Thats dependet on the driving phisics you have, the more arcady and stable, the more the AI will be able to handle it stable!
Instead of an input 1f you can create a dynamic input by divindng the angleToDir/70f so depending on how sharp the angle is it turns more or less wich looks smoother
your tutorials are really useful! ty!
Nice, thank you! This is helping me make Ai cars in my bike game
Awesome! Thanks for sharing this with everyone!
How would you go about integrating this with pathfinding? Ie if I have buildings in the way and I want the car to pathfind around them?
You should make a multiplayer tutorial
U should make tutorial vehicular combat like twisted metal
I have edited my comment. You are right. Thank you for your response.
Uh? Adding support for elevation needs to be added to your Driver script, not the AI script which is what this video is about.
The AI doesn't care if the target is above or below, it just goes forward, left and right. As long as your Driver script supports elevation this AI will get there.
Great video man, the tutorial is really awesome. By the way can you make some tutorials on procedural animation. There are not much tutorial about this topic in the internet.
Can I ask about the PC requirements to run such learning simulations? How long such example could take? Is there a way to benchmark mark and understand what type of hardware I need specifically for AI simulations? Like Processor, Ram and GPU? Appreciate your great and wonderful contents ☺️☺️
Police Obstacle Avoidance Please
Yes....very simple....
ah yes, I could make this in my sleep while struggling with very basic movement
Very helpful basis. Thinking of calling these ai drivers "monkeybrains".
Please help. For some reason my angleToDir calculation keeps oscillating very quickly between the same angle of a positive and negative value. I have debugged all the parameters within the equation and I still cannot figure out why this is happening...
This is great. Can I use it in another game engine also could you add a to use context based steering for the car to avoid other cars?
Sure you can implement that same logic in a different engine, in the end it's all math.
I put the CarDriver on my car but it doesn't work. Do i need to add anything else?
I'm having two issues. Mouse3D and GameHandler don't exist in the current context
me too
and me
Also me
me as well
I think it's about time you switch to visual studio dark theme
I would but dark theme burns my eyes
nice tut thanks u so much ez and useful :3
Instead of doing a Vector.distance couldn't you use the dirToMovePosition sqrMagnitude or magnitude before normalizing? Would this be better or equivalent in performance?
Thanks for the awesome video.
Sure that would work. Highly unlikely to have any noticeable performance impact unless you have thousands of AI cars.
CDProjekt Red: "I'll pretend I didn't see that"
it takes a little more work than that LOL
@@SubjektDelta but he is only o e person xD
@@NAME494 I guess you have never worked in a big game dev company
HAHAHAHAHAHAHAA Excellent. Unfortunatelly most of people doesn't understand irony. ....
Man you are the best
How can we just make the car move randomly on the ground without any targetPoint or path to follow? Like a fake multiplayer game?
Hello Code Monkey! I have a question for you, i thank you so much for this tutorial i learn to make something similar, but when my car is following the target, the car start to shake like if his turnAmount was to -1 to 1 to -1 to 1 everytime , you know how i can solve this?
Calculate the dot product and define a certain tiny minimum amount where below that you don't turn, it will prevent those micro adjustements.
@@CodeMonkeyUnity thank you bro, you are awesome, dont let try be better♡ greetings from argentina
0 dislikes very cool!
CarAi works strangely for me with blender models, they start to move sideways, there were also problems with scripts, but I fixed them. Can anyone please help? Is there another AI similar to this that is capable of avoiding obstacles for cars? I need for my rts.
i am fixed all my bugs
💬 Let's build a Simple Car Driver AI
Great for any Driving or Racing Game where you want a Car to go to a certain position
I used this when making my Racing RTS ua-cam.com/video/mNoyPz3LCy0/v-deo.html
Did you removed the playlist which contains complete tutorial for beginners for unity?
It's here ua-cam.com/play/PLzDRvYVwl53vxdAPq8OznBAdjf0eeiipT.html
@@CodeMonkeyUnity Thx but when I search something like "Unity tutorial for beginners" then your playlist comes up which has more videos like more than 30 or something like that. Okay, no problem! You would have some issues with that playlist I guess.
Though nice, I really do start to feel that the term AI (or Artificial Intelligence) is starting to lose its meaning. I guess that's always the case though in the context of showcasing some "basics". Weird though that we now start to consider ML to be what AI stands for :D
You give it a target point and the car figures out what actions to take to get there, that's Artificial Intelligence, a non-intelligent entity couldn't figure that out
The issue is that AI has become a buzzword that some people use in a much more limited way than the words actually mean.
This is Classic AI, I've also made a Car Driver using Machine Learning AI ua-cam.com/video/2X5m_nDBvS4/v-deo.html
@@CodeMonkeyUnity I guess what I was trying to say is: AI seems more automation than intelligence. Sure, there may be some wheight-based and/or priority based decision making along the way. Perhaps even complimented with some prng in there, but given the same parameters it will always behave the same way. It's a great way to approximate the appearance of intelligence. In that sense, I fully agree: It has become a buzzword. It was the best we could do at the time we started giving NPCs behaviours, but is it still accurate to call it AI, now that we have ML I wonder?
MachineLearning, within the confines of its rules, can/will evolve and change its behavior over time. To me, that's much more "intelligent" than what we attribute to AI. What we call AI, is more a reflection of how much effort was put into the development of the behavioural rules of "automation".
Anywho, I very much love your videos and my comment was not meant as a critique of the content. I was merely posting a thought that's been going through my head. I apologize if it came across as such.
A friend of mine once said:" AI is just a bunch of ifs"
im trying to make this in 2D, and the car will just keep going backwards no matter where i place the target, is there a fix?
edit: looks like it works on the z axis, ill see if i can solve it
edit 2: ill leave this comment here for who does it in 2D, just change the forward in dot to up and it should work
Yes for 2D you need to convert the logic from XZ to XY
why give the projectiles when it's incomplete/broken?
What projectiles?
scripts have errors. can't attach to cars.
Yep
Cyberpunk devs: 📝
Superb
It won't let me download the files, its saying I never to validate my email..I've done that ages ago and there's no new email in my inbox?
Maybe your mailer rejected a newsletter or reported it as spam, when that happens the email gets unvalidated to prevent it from sending emails to people who dont want them.
Try adding contact@unitycodemonkey.com to your whitelist and request another validation
@@CodeMonkeyUnity Its OK on the my PC ,need to wait for 7 days tho lol
Can someone help me?
I used to play a game in my phone 5-6 years back. It was a roller coaster game with different levels. In levels some tracks are missing, some tracks fall when you pass of them and there are passengers who fall it you ride carelessly.
If you know such a game, please tell me.
I believe RollerCoaster Tycoon has some mobile version
whats inside the CarDriver script file? Could you share it?
It's included in the project files linked in the description. It basically just moves the car along the transform.forward and rotates that game object, it's pretty simple
Does anyone know How I can try make game similar to Fire Emblem, I would like to try make a game with tose same machanics bit I don't know where to start. Dice I'm New to programming
That's a pretty complex thing to do if you're new to programming, I covered a Grid Based Turn Battle System here
ua-cam.com/video/mONHucoYASU/v-deo.html
ua-cam.com/video/0QU0yV0CYT4/v-deo.html
@@CodeMonkeyUnity Thanks brother, now I'm going to watch the videos to see if I get it, another question, do you know how I can make a button in the same action menu, that is, attack, special abilities, etc., that simply appears when my character has little life to transform?
Nice!!! like
Nice
Good 👍
how do i convert 2d platform to 8 directions
Hey brother please make a video on train androod controler with realistic acceleration and brake and orbit view+train selector and route selector
great
Love from pakistan
How do you convert this project to mobile? Thanks
The car doesn't care what platform it's being used on, there's no input here, you can set the target position in any way
so much hardcoding AAAAAHHHHH
Really? You think this is hard? CM teaches the basic. Still, always to see other ways to do things.
@@lee1davis1 hard coding = setting variables at runtime. for example the forwardAmount in the Update function.
no hard coding would be referencing them outside of functions and then use the reference.
What's hard about this one? It's all just a bunch of simple logic, it should be easy to follow along with the video
ilk yorum
you move too fast, talk too fast, don't explain things in multiple ways. for people like me in the #lowIqGang
Take your time, this is your learning journey, use the pause button as much as you need, just focus on learning.
@@CodeMonkeyUnity damn you handle that sort comments really well
what is a GameHandler in CarDriver.cs
#CodeMonkey estou usando unity 2022.2.6 e da erro Assets\CarDriverAI\Scripts\CarAITargetMouse.cs(13,40): error CS0103: The name 'Mouse3D' does not exist in the current context e Assets\CarDriverAI\Scripts\CarDriver.cs(100,43): error CS0103: The name 'GameHandler' does not exist in the current context
criei private Mouse3D; e esses erros acima some e aparece outro Assets\CarDriverAI\Scripts\CarAITargetMouse.cs(10,20): error CS1519: Invalid token ';' in class, record, struct, or interface member declaration
como resolver isso,por favor ajude-me.
O Mouse3D foi criado aqui unitycodemonkey.com/video.php?v=0jTPKz3ga4w
O ultimo erro, tens um ; num sitio onde não é suposto
@@CodeMonkeyUnity obrigado por responder, desejo sucesso no seu canal.