Download

Car AI - Blueprints and no Marketplace?

Hi!
I’m learning basics of AI in UE4. After being impressed by Character’s “AI Move To” using Navigation mesh, I’ve decided to do the same with a wheeled vehicle…but it didn’t work…what a surprise!

I’d like to ask you about the possibilities to make it work. I was trying to solve it by looking for a vehicle AI controller or something similar to work with but with no luck. When researching the YouTube videos, most of them were using some Marketplace scripts, a scary word “C++” or they were making advanced stuff like traffic.
Please, is there/what is the non-C++ nor Marketplace way to make cars simply go to the specified Target Point?

Thank you for any answer

Hi,

You can only use the build in “MoveTo”, if you have a capsule as root and it won’t work for vehicle movement.

Won’t be simple. But you can do it in blueprints (either blueprints or C++ you would need to do it from scratch) but of course blueprints would be (a bit) worse for performance.

Basically what you would do is you manually set the steering and throttle input of the movement component to reach the target location. Since most of the time you can’t just go in a straight line to the target location (there might be obstacles in the way), you need to make use of the navmesh. There is a node called “FindPathToLocationSynchronously” were you input a start and end location and it will return a number of “waypoints” based on the navmesh to reach the target location (the navmesh you use for vehicles would need to have a big enough agent radius, since the radius you need for vehicles is way bigger than the default). Then you would manually use the steering and throttle input to let the vehicle move through those points.

Thank you for your reply!
Meanwhile I tried to make the “AI” try to match player’s throttle and forward vector. I had quite a fun testing it, maybe I could make a small test-game with this. I thought myself - maybe it won’t be so bad, looks like a good UE-scripting practise to make it work. Probably I should try to make it in C++ in a future…well, I haven’t touched it yet and everybody discourages me.
Nevermind…

Thank you for this note! I wouldn’t find it by myself and according to what you say, it could be super useful.

Once again, thank you for your reply!

I started learning it after I learned blueprints, and I think it is easier and faster to learn blueprints first before c++, cause then you already know the nodes/commands there are and the workflows to use and “only” need to learn c++ (or I should rather say “unreals” c++, I never used any “regular” c++ outside unreal engine), and not c++ and the whole API simultaneously.

After a certain point though, knowing c++ will make your life much easier. Basically when you want to build something in blueprints, but the things you need are not exposed to blueprints (knowing a bit c++ will open up a whole lot of new possibilities) or plain can’t be done in blueprints without crazy workarounds =)

And of course you can offload performance heavy logic you build in blueprints to c++ if needed. But for complex things like your own vehicle movement, I would prototype it in blueprints anyway cause it is easier and faster for me than doing it in c++, and then I would move it to c++ if I need the extra performance.

Really nice to read it! That’s what I was planning to do, learn blueprints and when they won’t be enough, slowly switch into C++.
I’m glad I’m probably on the right way.
Thank you