Simple Move To Location is inconsistent and makes errors.

Hi!

I’m working on this online game that requires tile-based movement. There are multiple ways to approach this such as interpolating the position of the character from one tile to another but I’ve figured using Simple Move To Location would be easier since it’s replicated by default and make use of the character movement component.

Here’s the issue:

Simple Move To Location doesn’t expose the acceptance radius variable. Meaning, in theory, the character will consider its pathing to be complete when the edge of his capsule component touches the destination location. This result in my character not being centered on the tile.

This wouldn’t be much of an issue since I can just add half the radius of the capsule to my destination location to make the character appear in the center of the tile but for some reason Simple Move To Location is inconsistent

Here’s an example :
On a button press, I call the function to reach the destination location (1150.000000, 1850.000000, 98.337500) → (in reality, I ask the function to go to (1171.000000, 1850.000000, 98.337500) since I want the character to be at the center of the destination location and the capsule size is 42) but every time I restart the game, the end location is different.

Please take a look at the attached images.


How can I fix this ? And why this happens ? Is it due to the pathfinding algorithm ?

I know that AI Move To is better for these type of situations but this function is exclusive to AIControllers. Meaning, I would need to create some kind of janky architecture where my player controller tells the AIContollers what to do while also being the player and managing cameras, states and so on. (what does the player controller possess in this context?)

I appreciate any type of guidance, tips and help

Thank you!

Don’t use “simple move to location” in that case. Switch to “Move to location”. It has an acceptance radius parameter that drives how close can a character be to the target point before it is seen as reached.

Is MoveToLocation available in a player controller class ? I’m doing all of this in C++

in AIController.h

UFUNCTION(BlueprintCallable, Category = "AI|Navigation", Meta = (AdvancedDisplay = "bStopOnOverlap,bCanStrafe,bAllowPartialPath"))
AIMODULE_API EPathFollowingRequestResult::Type MoveToLocation(const FVector& Dest, float AcceptanceRadius = -1, bool bStopOnOverlap = true,
	bool bUsePathfinding = true, bool bProjectDestinationToNavigation = false, bool bCanStrafe = true,
	TSubclassOf<UNavigationQueryFilter> FilterClass = NULL, bool bAllowPartialPath = true);

You have exposed AcceptanceRadius

I cannot call this function on a standard player controller. It needs to be an AIController. It needs casting.

How can I manage the player controller and the AIController ?

You need to separate your camera pawn from your character pawn.

The pawn with the camera controls is what is in the world.
The character is spawned or placed into the world and is ai controlled.
Only then will the move to work correctly.

OFC you need to convert this to c++
Camera pawn (it’s the default character)

Game mode post login spawn

Move to in player controller

Oh nice! Do you know if this approach supports replication out of the box ?

No I doubt it.

You would need to give the move to command through a reliable server RPC (probably with validation) from within probably your player controller (you need to be the owner for it to trigger server side commands)

Maybe if you set the ai character to replicate and replicate it’s movement it might work.

But will require some configuring. It’s not MP out of the box.

Thank you, I greatly appreciate your time.

I’ll try this and update this if I managed to program it correctly

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.