MoveTo AI Task - How on Earth does the Character know what to do with it?

I’ve been sifting through for hours now, I’m trying to write basic vehicle AI for movement. All it has to do is apply input, which is relatively easy to long as it knows where it’s target destination is.

I have so far been able to get the AI to ‘Plot’ a path just using Get Path To Location, which is fine. The problem is, how do I then tell the movement component that ‘this’ is the next Path node to go to? Currently I’m doing this in Blueprint, which makes the actor go to the first pathpoint, but then how do I tell it to go to the next one? Do I literally have to manually tell it to go to this point, then this one etc? Additionally, how does that work when it’s pathing to an Actor, and the path updates?

‘Move To Location’ is a blueprint function I wrote, that works out what Input to apply to the vehicle based on the location it’s given and it’s current velocities etc.

I want to program my VehicleMovementComponent so that it works with the default engine AI Tasks, but I can’t figure out where CharacterMovementComponent actually works out what it’s supposed to do with ‘MoveTo’. In CharacterMovementComponent and NavMovementComponent, I can see ‘RequestDirectMove’ - which is the ONLY reference to AI movement I can find, but i can’t find where it’s being called from, or why on earth it takes in a Velocity instead of a location. …



virtual void UNavMovementComponent::RequestDirectMove(const FVector& MoveVelocity, bool bForceMaxSpeed);


Documentation is next to zero on this (everybodies making games with characters… bleh), so how do I make this work?

I don’t have time to help much right now, but I think the part of the engine code you are probably missing so far is UPathFollowingComponent. To oversimplify a bit, you have the navmesh which is used to generate paths, then the path following component to tell the movement component where to go next, and the movement component is responsible for how a pawn moves.

The behavior tree just sits on top of it all and determines what to do and when, on a higher level.

You can hit me up on Slack if you have more questions, though I won’t be on until after the weekend probably.

Cheers Kamrann, that’d be great.

I put a quick little test together. Threw a BT together with a ‘MoveTo’ task in it, and set my vehicle to use it - all it tries to do is ‘MoveTo’ the player. I overrode ‘RequestDirectMove()’ in my MovementComponent and printed out the Velocity. It’s a huge number, but it changes as I move around, so it appears like that is one of the injection points from the PathFollowingComponent -> the MovementComponent.

What confuses me is… why velocity… why not Location instead, that’d make a hella-lot more sense.

Looking at the code, it’s the velocity required to get to that destination in one frame - and the destination is the ‘next’ path component. So this is cool, if i normalize it I get the direction I’m meant to travel in, but I can’t tell it when it needs to start slowing down.