Why is "Simple move to location" not working as expected?

I’m trying to create a simple a-rts(moba) kit using blueprint. I started messing around with the Top Down template.
I’ve created the camera but now I can’t figure out how to “click to move” properly. I’m using the “Simple move to location” but it seems that it doesn’t work as I expected to. The character never reaches the click location. It just stops near it.

Is this a “simple move to location” function problem or am I missing something?

Hey,

If SimpleMoveToLocation doesn’t quite give you what you need then you’ll need to use to a more generic solution, which is calling MoveToLocation or MoveToActor on an AIController. The parameter you need to adjust here is AcceptanceRadius which basically specifies how close to goal location you want AI to end up. Expert’s tip: don’t use zero even though it’s a valid value.

Let me know if you need assistance in getting an AI controller from a Pawn.

Cheers,

–mieszko

Hi,
Thanks for your answer. That’s what I’m trying to do all day but can’t figure it out. So I will appreciate your help getting an AI controller from the Pawn.

Picture is worth a thousand words!

–mieszko

Thank you very much. I didn’t know Casting was some type of conversion. Although in my case it’s always failing, I’ll figure it out by myself eventually.

It’s quite possible your controller is not an AIController. As far as I remember TopDown’s implementation details it’s using SimpleMoveToLocation because it’s a PlayerController that’s driving the pawn on the map, and as such doesn’t have access to AI functionality. The proper solution here is to have an AIController-driven pawn, and has a body-less player controller that tells AIController where to go.

I finally managed to get what I wanted. But I encountered another problem. If I click near the Pawn, it starts running towards the 0,0 position instead of the click location. Having an acceptance radius of 90 eliminates this problem, but that’s what I was trying to avoid from the beginning.

What does log say? Make navigation and pathing logs verbose by calling these in the console:

   log LogNavigation verbose
    log LogPathfollowing verbose
    log LogCharacter verbose

And copy-paste it here. Which approach did you take to get desired behavior?

LogNavigation: MoveToLocation: Goal(X=-510.180 Y=79.766 Z=120.000) AcceptRadius(10.0) bUsePathfinding(1) bCanStrafe(1)
LogNavigation: NotifyPathUpdate points:2 valid:yes
LogPathFollowing: UpdateMove: Path(complete:2) Status(Idle) RequestID(0)
LogPathFollowing: UpdateMove: invalid request
LogPathFollowing: RequestMove: Path(complete:2), AcceptRadius(10.0), DestinationActor(None), GameData(missing)
LogPathFollowing: RequestMove: accepted, ID(16) dist2D(29) distZ(8)
LogBlueprintUserMessages: 94.568092
LogCharacter:Verbose: Setting base on server for ‘MyCharacter_C_0’ to ‘ModelComponent /Game/Maps/UEDPIE_0_Example_Map.Example_Map:PersistentLevel.ModelComponent_508’
LogPathFollowing:Verbose: [agent to segment end] dot [segment dir]: 0.321344
LogPathFollowing:Verbose: dist 2d: 516.378052 (agent radius: 10.000000)
LogPathFollowing:Verbose: Z diff: 7.850021 (agent halfZ: 88.000000)
LogPathFollowing: OnPathFinished: Blocked

Right now, I’m using an AIController to “drive” my character.

Can’t really tell what’s going on from this. How about you grabbed a VLog for me? Run VisLog command, press record and start playing. Make AI do the buggy behavior, stop recording, select AI controller name in the LogVisualizer and press the save icon. Send the resulting file over, please :slight_smile:

ai.vlog
I did some valid movements and some with the buggy behavior. ( I upload it on sendspace since the site doesn’t allow me to upload it as an attachment)

Hi Can someone explain how to set the AIcontroller get controlled by the player controller (since it is not possible to cast player controller to AIController) ? Just a few guidlines please

It’s not possible. However you can have PlayerController interact with AIController by, for example, requesting move.

Oh I get it now thanks !

Hello

I have a similar problem to the OP and wish to change the acceptance radius for my PathFollowing component in c++. I’ve been reading through the API and cant seem to find anything to get access to that component or change the acceptance radious value.

I see the SimpleMoveToLocation() function creates a pathfollowing component, but Im not sure how to access it or get it outside of the function. Im new to c++ as well, so any help or suggestions would appreciated greatly :slight_smile:

If we’re talking about C++ solution the easiest way is to derive from UPathFollowingComponent and set MyDefaultAcceptanceRadius in that derived class’ constructor. Then make your AI use that derived path following component. You can find more details here: A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums1-_Making_AI_Jump_as_a_Part_of_Path_Following

If you want to solve the problem in blueprints just don’t use SimpleMoveToLocation, use other Move To functions, like AIMoveTo or simply use Behavior Trees that give you a lot more power.

–mieszko

Hey Meiszko,

I am following your tutorial, but instead I’m applying this new Path Following Component to my Player Controller, and not an AI controller. I cannot seem to create a derived PathFollowingComponent. The moment i go, Add Code To Project in the Editor, select the derived class to be PathFollowingComponent, then open the code in VS I get a an error.

VS claims:
Error: SuperClass PathFollowingComponent of class MyCharacter_PathFollowingComponent not found…

How is this possible when I just derived this class from PathFollowingComponent?

I dont see how this could be affected by my PlayerControllerClass because I have not even told it to use the new path following component yet.

It seems that your project is missing AIModule dependency. It has been already answered here

Regarding applying path following component to your player controller, you can’t just do that the same way it’s done for AIController since PlayerController doesn’t have a path following component out of the box. The SimpleMoveToLocation function creates one for a given controller which boils down to spawning one in case of PlayerController. You can modify this behavior to spawn your component by overriding AController::InitNavigationControl in your player controller class.

Hope it helps!

why should we not use 0 as a value?

Because you’d get potentially endless jitter on the final step, depending on your FPS. Requiring stuff to happen with 0 error margin is never a good idea for game AI :wink: