What if we don't override RequestDirectMove()?

If I understand this correctly, we are intercepting the RequestDirectMove() function so that we can force the AI tanks to use an identical control scheme. So far, so good. Ben said that if we didn’t do this, then the tanks would move “unnaturally”, and as I’m a sucker for seeing software self destruct, I went ahead and removed our override of this function (leaving MoveToActor() in place)… but the AI tanks don’t move at all! I’ve got my navmesh set up correctly, as when overriding the function I get the logs correctly printing to screen (when outside the minimum radius), but with it the override in place… nothing.

How come?

1 Like

Ok, after many hours of poking around, I’ve finally got an answer for this!

RequestDirectMove() sets an FVector Velocity in its un-overridden state. Our UTankMovementComponent inherits from UNavMovementComponent, but there are no functions in UNavMovementComponent that actually utilise Velocity, resulting in the AI tank being unable to move.

The highest level class inheriting from UNavMovementComponent that uses Velocity is UFloatingPawnMovement, which means if you change UTankMovementComponent to inherit from UFloatingPawnMovement, then in its unoverridden state, the AI tanks now slide towards the player tank as expected!

I know this is a moot point as we’re overriding this behaviour through RequestDirectMove(), and I’m definitely not suggesting that we should alter our code to inherit from a class further down the inheritance tree, but for anyone else curious as to why the unoverridden function doesn’t produce AI movement, hopefully this will answer that question!

4 Likes

Privacy & Terms