Hi,
I am currently working on a project for which I want to use a custom MovementComponent. At the end I would like to have a Pawn, that can be controlled by an AIController and that has custom Movement functionality. The reasons why I don’t want to inherit from the UCharacterMovementComponent is firstly, that for my project I simply do not need most of the functionality. More simplistic Movement would be better. Secondly because I like using self-made systems, since then I am much more familiar with them and can use them much more efficiently. And thirdly, simply because it will teach me a lot about UE and programming in general, especially when it comes to movement replication. However I have run into a few problems. I’ve spent two days browsing the source-code behind the AI-controller, MovementComponent hierarchy and the Character hierarchy, but since it is a lot of code and I only have a few years of coding experience, I only understand parts of it and this method doesn’t seem to work. So I would like to ask the following three questions. I inherit from APawn, AAIController and UPawnMovementComponent.
My first question is: Which function does the AIController use in order to move a Pawn? In other words: Which function do I have to override in oder to make the AIController move my Pawn? For me it looked like it calls “RequestDirectMove” or “RequestPathMove” in the UNavMovementComponent, but when I overrode those to display the vector they produce, I got nonsensical, weird results (Zeros in the case of the latter and very big numbers in the case of the former, which became 0 when I tried to normalise them. However the at least seemd to go in the right general direction). So which function of which class am I suppest to override when trying to make the AIController call custom movement functionality (During pathfinding primarily)?
My second question: When I try to move my a pawn, does a Movement function that implements collision already exist, or do I have to make one on my own? In the former case: Which function would that be? In the latter I would really appreciate a quick reference to where I can find further information about this topic. I understand the theory behind collision, but I have no idea which functions have to be used in practise and which source variables I can use.
My third question revolves around movement replication, or replication in general. Its fairly simple: If I set a variable to be “replicated”, how much can I rely on the engine to replicate it efficiently? If said variable changes every frame, updating it ever frame would be costly. Can I rely on the engine to space updates in a way, that doesn’t slow down the overall connection? What if I had 100 variables like that, obviously a single variable had to receive fewer updates, but does the engine think of that? Or do I have to make sure that the connection isn’t flooded with information? And a small bonus question: I know that I can set the repliaction-priority for Actors, but is there a way to do the same for single variables?
I have looked through countless tutorials and, as mentioned, I have spent many hours browsing the source code of ACharacter, AAIController, the classes they inherit from and their Components, but I got no useful results with that method. So I would really appreciate someone helping me out here. Thank you in advance.