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