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?
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.
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.
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.
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
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
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
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.
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.
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