Finally. The last issue is resolved. Only polishing is left.
- Paul Swarrow
- Jul 28, 2023
- 2 min read
I was not able to override AIController MoveTo as I wished. But I've found a workaround: C++ static function + Macro Library blueprint. It goes like this:
C++ function takes pawn to move and other AI Move To input parameters.
If target is location: check if it is on the dynamic surface and convert it to virtual space if needed
If target is actor: create a marker actor that will follow the target as a projection in virtual space.
If the pawn is on the dynamic surface: use it's ghost in the virtual space instead.
So, after this I can just use native AIMoveTo.
Sadly I can not call AIMoveTo from C++ so I had to make a simple Blueprint:

Just need to destroy Marker actor after movement is finished:

Result:
Red gizmo is a marker syncronazed with AI Move To target
Blue gizmo - projections of the characters from ship to a virtual space.
Also, it starts to make sense to rely on the ghost character all the time even if the original character stands on static ground. It will potentially simplify path calculation from ground to dynamic surface. Or between two surfaces, oh yes! Boardings!
All in all the solution is not too dirty! The question is: how expensive it is. Each AIMoveTo will spawn and destroy an additional actor. It could be costly if there will be lots of constantly moving characters. This is the case in my pet-project. But as I can see UE5 use pool from the box as it reuses the same marker all the time, so maybe it is not costly at all!
I have to create some benchmark scene later. it will be very useful for measuring what scale I can afford in my pirate game.
Comments