How to make your own Move To Actor or Location node from scratch?

I’m making a game with AI but I want to have more control over how they move. I’m finding the Move to Location or Actor node is a bit lacking in features that I would like it to have, and have determined that the only solution is to make my own from scratch.

This wouldn’t be the first time I’ve made my own version of UE code from scratch, but it’s definitely the most complex one so far.

To make my life a lot easier and faster, I would ideally like to see exactly what happens to all the inputted data once the existing node is called, so that I can make my own and make the needed additions.

If anyone has any readable (high quality) source of images for what it looks like inside that node, I would be extremely grateful. I myself am unable to “go to definition” (for nodes that have that option, obviously this node does not have that option), as nothing ever happens when I try, and the “View Documentation” option is always greyed out, not that the online documentation pages have ever historically been all that great or detailed.

A little backstory for why I want to do this. Basically I’m making a game where I want to prevent the AI from changing rotation when they move (they should not be “facing” the direction they are “moving in”), as I have a specific way I want them to face at all times. Think of Tank Controls for instance. Your facing while driving a tank is not always the same as your movement direction. Well I have AI that needs to function similarly to that. But the Move To nodes that exist do not give you the ability to prevent them from changing rotation, and as far as I can tell there is no pre-existing way to lock rotation. Only thing you can do with the pre-existing code is to manually set the rotation to the way you want it. Problem is, even with the fastest FPS, the human eyes can still see the split second where the rotation is incorrect. It’s extremely irritating, but you almost never see any issues with that in released videogames. So I basically want the solution (or trick) to making this work as it should be. The only solution I can think of is to take away the ability to change rotation from the MoveTo nodes by – you guessed it – making my own MoveTo node. I plan to add in a boolean input (either for all 3 rotations at once, or one per each rotation axis) where, within the node, it checks the state of those booleans, and if they are false, rotates as expected on those axis for a ‘regular’ movement. If those bools are true however, it moves the actor without changing those rotation values. Thus creating the ability to CHOOSE if I want human/car/plane/tank/etc camera movement controls.

TLDR: MoveTo nodes don’t give you the ability to do some things I want to be able to do, so I need to make my own. Any and all help will be appreciated!

The only thing you mentioned that you wanted to change from the base node is it looking where you want.

You don’t need to reinvent the wheel for this, you can just uncheck the box in the movement script “Orient Rotation to Movement”

Mine’s already set to disabled for that. Doesn’t seem to make a difference.
should not be rotating but it is

I set it this way initially when I created my custom rotation for the player character. Likewise the AI character has it disabled, but the AI character’s movement is done via Move To Location or Actor in the Behavior Tree. Even removing all my custom movement and rotation code, it still has the same issue. So I assume the Move To Location or Actor node is doing both the movement and the rotation, because there’s nothing else that could be doing it.

I’m not sure why that’s happening.
The top down controller template uses move to, and it works for that.

1 Like

Ah, there’s a Simple Move To Location and Simple Move To Actor node. I did not know that.

I assume that node doesn’t change rotation? If so, that’s immensely useful. That gets me one step closer to what I’m looking for. :slight_smile:

Turns out, even Simple Move To nodes change the rotation of the moving actor to match the direction it has to move in towards the destination. It seems I just can’t win with any of these premade nodes.

1 Like

You can use SetFocus to make the AI look at something. Enable “allow strafing” (or something like that) in the MoveTo call so that it can move towards destination while looking at focus target.

That would work if I had a specific target to have it look at. In my case I just want the specific entity to look a specific way when moving, not at a specific target, without the way it’s looking to necessarily be the exact same direction that it’s moving towards.

OMG I found the problem. While I did have Orient Rotation to Movement (in Character Movement component) as false, in the Character’s Pawn variables section, I had Use Controller Rotation Yaw enabled. Disabling that fixed it. Now my AI characters change rotation from my code alone, and not from any movement forced rotation.