Questions about AIController and Movement Components

In my game, characters always stand on a Pawn called “Chessboard,” and each Chessboard has 10 positions where characters can stand.

Player input causes the Chessboard to move, and the characters try to move to their corresponding positions on the Chessboard. Currently, the character movement is implemented by calling MoveToActor() every tick.
CharacterMove

However, there are some issues:

  1. Once the character touches the collision volume of the target Actor, it stops moving. I want the character to move further into the center of the collision volume, but even setting StopOnOverlap to false and AcceptanceRadius to 0 doesn’t seem to work.
  2. Unreal Engine only allows Actors and Vectors as movement targets. I want the actual movement target to be a DecalComponent under the character’s feet. Creating a temporary Actor and attaching it to the Decal is very inelegant—I’m looking for a better approach.
  3. Calling MoveToActor() every tick also feels inelegant. Are there any clever solutions to this?

If it’s necessary to override some classes with C++, I’d prefer the solution to not be overly complex.

In short, I’m looking for inspiration and ideas. Thanks!

It seems like the movement is 2 dimentional. So why don’t you just create a spline that starts from the player character’s location and ends at the target location? (With the same z component of the player character’s location) Or it can also be a really long spline that’s middle point is the target location. But do not attach the spline to the moving player. Once that’s done, constrain the movement to the spline by constantly setting the player character’s location to the closest location on the spline (by using the Find Location Closest to World Location node and making sure to set the coordinate space as World), move the character to the target location’s direction by either subtracting the character’s location from it, normalizing the result and setting it as direction in the Add Movement Input node; or setting the target location for movement as a point far away on that direction, then end the movement once the character’s location is the same with the spline’s end point. (It can be the point with index 0 or 1, it depends on your implementation) The reason you can’t simply trigger something when an actor’s location is the same with a target location is because their location will most likely not be the exact same even if the character passes through that location due to float precision. But you’ll be able to detect when your actor reaches the exact target location this way! Hope this helps :blush:

Thank you! I haven’t tried using splines yet, but it does sound like a good solution for more precise movement control. If the movement is along a straight line, it should work fine, but for more complex trajectories, this approach might mean abandoning the engine’s pathfinding, obstacle avoidance, and navigation mesh functionalities. These features are really hard to give up.

Nope, you can create intricate trajectories using splines too! Just increase the points :innocent:

You can still use pathfinding while constraining the movement to the spline. Just make sure that the spline doesn’t go to another way than the intended path.

Though keep in mind that you also can’t detect that precise location detection for spline points that are not on the edges. So make sure that one of the tips of the spline is set as the target location.

Do you mean I can directly create a spline and hand it over to the Path Following Component or AI class to handle? Or is it possible to access and modify the path they generate?

Are there specific function names or class names related to this? My understanding of pathfinding and movement is still quite basic, so any help would be greatly appreciated. Thank you!

No, you see, the character will already try to move to the determined directions. For example, if you give your character a movement direction to the +y direction but it’s movement is constrained to a bumpy spline, it will still move along that spline while moving to the +y direction. It might get slower at bumps, but still, it will move accordingly. To avoid that inconsistency in the movement speed, it’d be best to keep the spline’s length that’s gonna be traveled as short as possible to keep it’s trajectory similar with the intended movement path.

Hey @user_473504a1534af3b6e5e5991bf13750e943fdd811b6fe7fb2bb234a, it’s been a while since we last heard from you! Were you able to implement the approach I suggested, how did it go? Do you have any updates to share?

Thank you, big bro, for still paying attention to my thread after all this time.

Forgive me for being a bit slow; I may not have fully grasped the solution you mentioned earlier about splines (possibly due to language barriers, as machine translation struggles to convey complex ideas).

Over the past few weeks, progress on this project has been relatively slow because I’ve been busy with many other things.

In any case, here’s how I’m currently handling character movement: since the character can only move to a FVector or an Actor, I created some “guide pole” Actors to direct the character’s movement. I set these Actors to have a relatively large collision volume but kept their appearance thin.

Although this solution isn’t very elegant, it meets my needs for now.
CharacterMove2

1 Like